Sign In Register

How can we help you today?

Start a new topic
Answered

Re-Login deletes my PlayerPrefs

Hi, 


I'm new to gamesparks and am trying to integrate its login without any social network (GameSparks' own username/password that is). So far I've more or less managed to get the result I want, however I have couple of problems. 


The system I currently have works in the following way:
When a player presses a leaderboards button for the first time, two textInputFields appear where the username and password must be written. The window also has three buttons - "REGISTER", "LOGIN" and "CANCEL". When the username/password fields are filled in, if the register button is pressed the username is registered (unless it's taken) and if login is pressed, the player logs in (if the password matches the username). After that the same button opens up the leadboards but has an extra button which enables players to relogin as someone else. 

My first problem is, if I log in as Player1, then play the game for a while, and re-login as Player2, all the PlayerPrefs get deleted. 

Below is the code for Register and Login methods

Register:  

	public void Register()
	{
		SetInput ();
		new GameSparks.Api.Requests.RegistrationRequest().SetDisplayName(gsUsername).SetUserName(gsUsername).SetPassword (gsPassword).Send((response) =>
		{
			if (response.HasErrors)
			{
				print (response.Errors);
				// if usename is already taken the do
                                // feedbackText.text = "username already in use,\nplease choose another one";
			}
			else
			{
				feedbackText.text = "Registration Successful!";
				Invoke ("CancelButton", 1.5f);
			}
		});
	}

Login:

public void Login()
	{
		SetInput ();
		new GameSparks.Api.Requests.AuthenticationRequest().SetUserName (gsUsername).SetPassword (gsPassword).Send((response) =>
		                                                                                                                                   {
			if (response.HasErrors)
			{
				print (response.Errors);
				//if username and password don't match, say that they don't match
			}
			else
			{
				feedbackText.text = "Login Successful!";
				Invoke ("CancelButton", 1.5f);
			}
		});
	}

My second problem is, how do I check which error was returned in the response?

In "Register" code for example I want to be able to know if the error returns "username taken" and if it does then print out the feedback text, while if error is something else, handle it differently.

Same in the "Login" code. If the username and password don't match, I want to know it. 
I tried printing `response.Errors` but it doesn't show anything special.


Thanks in advance


Best Answer

Hi Sandro,


If you want to remove entries from a leaderboard first select the Manage tab in the portal.



In the next column select the "Dynamic Leaderboards" tab and you should have a list of leaderboards for that project.



Click the button to the right of the leaderboard to edit the entries.



Here you can either select an entry to delete or delete them all.


Thanks,


Oisin.



so I can't access passwords either as a gamedev? Damn, I wanted to be god! : \

here's a test harness request and response copy


{
 "@class": ".AuthenticationResponse",
 "error": {
  "DETAILS": "UNRECOGNISED"
 },
 "newPlayer": false,
 "scriptData": null
}

{
 "@class": ".AuthenticationRequest",
 "password": "password",
 "userName": "GameSparksShane"
}

while we're at it, should I manually save player's login and username credentials so that on the next game boot up they are logged in automatically in the background or does GameSparks handle that itself somehow? 
Right now it seems that in Unity Editor (I don't have the device with me at this moment), when I start the game, it sends the "AuthenticatedConnectRequest" which makes the "GameSparks.GameSparksApi.isAuthenticated()" return true. But I think it is not logged in as any user right?


I need to check if the user is already logged in or not, to then either present the login screen or show the leaderboards, and I think in this case "isAuthenticated()" won't do. How do I check for this?


Also, how do I check for the event when GS is Available? I need this so that as soon as GS is available I can login the player automatically


Lastly, are there any restrictions I should keep in mind for usernames? I mean should I only allow alphanumeric values, or is "Standard" setting ok? (which lets you put pretty much anything you want).
I limit both, the username and password, to 10 characters max.

Ok, I figured out the login thing.

The problems that currently remain are:

1. The thing with passwords, that I can't login to GameSparksShane for example
2. How do I delete test users? https://www.youtube.com/watch?v=3XhK-FJrwH8&feature=youtu.be&t=20m4s in this tutorial, on 20:12, you show how to do it but in my list there is no delete (or edit) button...



Removing leaderboard data seems to be intentionally restricted from No-SQL.

However,

       You can delete them easily with well designed new "Manage" tab section.




Good luck!


Hi Sandro,


The image you are showing contains a leaderboard. You can no longer delete leaderboard entries in this manner, you must do it through the manage screen. If you load the player collection, you should see this button.



Shane

I removed it from the player collection but it still shows up in the leaderboard...

Answer

Hi Sandro,


If you want to remove entries from a leaderboard first select the Manage tab in the portal.



In the next column select the "Dynamic Leaderboards" tab and you should have a list of leaderboards for that project.



Click the button to the right of the leaderboard to edit the entries.



Here you can either select an entry to delete or delete them all.


Thanks,


Oisin.


Done, thanks Oisin!


I still can't login to all the old users I created, not that's it's a huge problem anymore since so far all the new registered users seem to not have any issues with passwords but do you guys have any update on what may have caused the password related problem?

I think you may have had a mix up between the usernames and the display names.

The display names you defined had conventional seeming names but the usernames were more randomized.


Shane posted above that he was able to log in those users in your project using their "true" usernames.


If you go to the manage tab again you can see all existing usernames and display names in the "players" section.


Thanks.


Oisin.

Hmm, strange.

I just checked and the ones that I can't login with have identical userNames/displayNames. It couldn't be otherwise since when I register from the game, the one and the same variable is passed for both, display and usernames, and thus they cannot be different.

Anyway, it doesn't matter at this point, I won't bother you again unless something stops working or I fail to find relevant documentation for a given task : )

Thanks a lot for support!

Login to post a comment