- Home /
PUN and mysql database
Hey Buddies, I want to know if I want to use an existing database made in mysql for authentication in PUN, How can I do that? See I have a game made in native and now I want to make that game in unity but I want my old users not to sign up again so that is why I need my old Mysql data to be used for authentication. Now, first If I can do that by using the custom server authentication then how I can use that and how it will link to my database? and if Not then How can I achieve this? According to me connecting to photon and database separately is not a good option, so please suggest me something like this that I have to make just one connection to photon and from that I can access my database to.
Regards, M_Yadav
Answer by Landern · Oct 26, 2015 at 01:01 PM
The documentation spells it out for you (Custom Authentication PUN), Pun will receive the authentication information(i.e. user/pass combo) which will be passed to your server in a query string.
So client side you will use Unity's GUI(or whatever you'd like) to allow the user to input their User and Password values. This will be passed to a base URL that you specify in your PUN account.
Example: http://www.exampledomain.com/login?user=userNameFromUnityUIControl&pass=passwordFromUnityUIControl
You will need to create a server side application/script to parse and check your MySQL database. They have put up a MVC(.net/IIS setup) example on github(https://github.com/exitgames/photon.custom-authentication/blob/master/src/Asp.Net.MVC/ExitGames.Web.Sample/Controllers/ClientController.cs). That is just for the login controller. You should use Ruby or PHP or whatever floats your boat. The important thing is to send back the correct json result/response to indicate whether the authentication request was successful or a failure. The server side part is completely up to you and your mileage will very depending on what YOU want to support on the backend.
PUN gets you part of the way there, you have to do the rest.