public void AuthenticateUser(string userId) { JSONObject obj = new JSONObject(); obj.AddField("userid", userId); LoginResponse loginResponse = new LoginResponse(connection.MakeRequest("login", obj)); //When unable to login if (loginResponse.hasFailed()) { //Benutzer existiert noch nicht if (loginResponse.IsAllowedToCreate()) { //Es dürfen neue Benutzer registriert werden RegisterResponse registerResponse = new RegisterResponse(connection.MakeRequest("register", obj)); //When user registred successfully if (!registerResponse.HasFailed()) { loginResponse = new LoginResponse(connection.MakeRequest("login", obj)); if (!loginResponse.hasFailed()) { this.Player = new Player(); var lastLoginTime = loginResponse.GetLastLoginTime(); this.Player.LastLoginTime = lastLoginTime; var playerId = loginResponse.GetPlayerId(); this.Player.Id = playerId; var oldHighScore = loginResponse.GetHighScore(); this.Player.Highscore = oldHighScore; this.Player.identNo = FB.UserId; } } } } else { //User successfully signed in this.Player = new Player(); var lastLoginTime = loginResponse.GetLastLoginTime(); this.Player.LastLoginTime = lastLoginTime; var playerId = loginResponse.GetPlayerId(); this.Player.Id = playerId; var oldHighScore = loginResponse.GetHighScore(); this.Player.Highscore = oldHighScore; this.Player.identNo = FB.UserId; } Debug.Log("Heyo"); }