Remember me prevents user from signing in a second time
Wirlaburla opened this issue · 3 comments
Unity Version: 2018.2.6f1
API Version: 2.5.2
I have the Game Jolt sign in screen only shown when the current user equals null, and it is in Awake(). However, when I click the remember me options on the sign in screen, it works for the first time, but after that it complains about an invalid token/username. This seems to be happening on both Windows and Linux, but those are the only two I have tested.
The output suggests it still thinks the user is signed in, but it equals null.
This happens in both the editor and player. It can be temporarily fixed in the editor if you clear the settings and re-enter what you had before, but do not check remember me.
That's because the API will automatically try to log the user in, when the game starts (Awake of the GameJoltAPI
class). So when you check for the user in your Awake methode, it is null because the APIs Awake function was not yet called. So you show the login screen to the user, meanwhile the GameJolt server has answered and we now have a signed in user, therefore when you click on "sign in", there is already a user signed in.
Therefore you might want to do something like this instead:
void Start () {
string name, token;
// check if there are no stored user credentials
if(!GameJoltAPI.Instance.GetStoredUserCredentials(out name, out token)) {
GameJoltUI.Instance.ShowSignIn(success => Debug.Log(success));
}
}
But I think I will still improve the autologin mechanism a bit, such that you can register a callback for such things directly
Ah, I was wondering about Awake and the API after I made my issue. Thanks for the explanation.
@vencorr I've added an UnityEvent callback to the GameJoltAPI object, which can be used to overcome this issue. The new version is not yet on the AssetStore.