private void OnLoginSuccessful(LoginResult userResult)
        {
            OnLoginSuccess?.Invoke();
            var messageService = Application.ServiceLocator.Instance.GetService <Views.Domain.Entity.IMessage>();

            messageService.MessageToShow($"Logged in!");
        }
        private IEnumerator SignUpCoroutine(Credentials credentials)
        {
            //string json = JsonUtility.ToJson(credentials);
            string json = string.Concat("{ \"username\" : \"", credentials.username, "\",\"password\" : \"", credentials.password, "\",\"country\" : \"", System.Globalization.RegionInfo.CurrentRegion, "\" }");

            string url = "https://isartdigitalf2pscrawl.herokuapp.com/users/signup";

            using (UnityWebRequest req = PostJson(url, json))
            {
                yield return(req.SendWebRequest());

                if (req.isNetworkError || req.isHttpError)
                {
                    Debug.LogWarning(string.Concat("[ServerManager] Cannot access to server or database at Sign Up, reason : ", req.downloadHandler.text));
                    Screens.Login.Instance.LoginFailed(req.downloadHandler.text);
                }
                else
                {
                    Credentials receivedCreds = JsonUtility.FromJson <Credentials>(req.downloadHandler.text);
                    credentials.token = Token = receivedCreds.token;
                    credentials.id    = receivedCreds.id;

                    OnLoginSuccess?.Invoke(credentials);
                    //PlayerDatas playerDatas = new PlayerDatas();
                    //OnGettingDatasSuccess?.Invoke(playerDatas);
                    //LastPubDate date = new LastPubDate(credentials.id, System.DateTime.Now);
                    OnStartFTUE?.Invoke();
                    //SaveLastPubDate(date);
                    //AdsManager.Instance.GetLastPubDate(date);
                    //SavePlayerDatas(playerDatas);
                }
            }
        }
    private void AuthenticateGooglePlayGames()
    {
#if GOOGLEGAMES
        PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
        {
            TitleId               = PlayFabSettings.TitleId,
            ServerAuthCode        = AuthTicket,
            InfoRequestParameters = InfoRequestParams,
            CreateAccount         = true
        }, (result) =>
        {
            //Store Identity and session
            _playFabId     = result.PlayFabId;
            _sessionTicket = result.SessionTicket;

            //check if we want to get this callback directly or send to event subscribers.
            if (OnLoginSuccess != null)
            {
                //report login result back to the subscriber
                OnLoginSuccess.Invoke(result);
            }
        }, (error) =>
        {
            //report errro back to the subscriber
            if (OnPlayFabError != null)
            {
                OnPlayFabError.Invoke(error);
            }
        });
#endif
    }
Exemple #4
0
    private void AddAccountAndPassword()
    {
        if (OnLogMessage != null)
        {
            OnLogMessage.Invoke("AddAccountAndPassword Start");
        }
        //Any time we attempt to register a player, first silently authenticate the player.
        //This will retain the players True Origination (Android, iOS, Desktop)
        SilentlyAuthenticate((result) => {
            if (result == null)
            {
                //something went wrong with Silent Authentication, Check the debug console.
                OnPlayFabError.Invoke(new PlayFabError()
                {
                    Error        = PlayFabErrorCode.UnknownError,
                    ErrorMessage = "Silent Authentication by Device failed"
                });
                RegisterAuthenticate(result);
            }

            //Note: If silent auth is success, which is should always be and the following
            //below code fails because of some error returned by the server ( like invalid email or bad password )
            //this is okay, because the next attempt will still use the same silent account that was already created.

            //Now add our username & password.
            PlayFabClientAPI.AddUsernamePassword(new AddUsernamePasswordRequest()
            {
                Username = !string.IsNullOrEmpty(Username) ? Username : result.PlayFabId, //Because it is required & Unique and not supplied by User.
                Email    = Email,
                Password = Password,
            }, (addResult) => {
                if (OnLoginSuccess != null)
                {
                    //Store identity and session
                    _playFabId     = result.PlayFabId;
                    _sessionTicket = result.SessionTicket;

                    //Report login result back to subscriber.
                    OnLoginSuccess.Invoke();
                    if (OnLogMessage != null)
                    {
                        OnLogMessage.Invoke("AddUsernamePassword Success");
                    }
                }
            }, (error) => {
                if (OnPlayFabError != null)
                {
                    //Report error result back to subscriber
                    if (OnLogMessage != null)
                    {
                        OnLogMessage.Invoke("AddUsernamePassword Fail");
                    }
                }
                if (error.Error == PlayFabErrorCode.AccountAlreadyLinked)
                {
                    RegisterAuthenticate(result);
                }
            });
        });
    }
        private IEnumerator LoginCoroutine(Credentials credentials, bool FromLocalCredentials)
        {
            string json = JsonUtility.ToJson(credentials);

            string url = "https://isartdigitalf2pscrawl.herokuapp.com/users/login";

            using (UnityWebRequest req = PostJson(url, json))
            {
                yield return(req.SendWebRequest());

                if (req.isNetworkError || req.isHttpError)
                {
                    Debug.LogWarning(string.Concat("[ServerManager] Cannot access to server or database at Login, reason : ", req.downloadHandler.text));
                    if (FromLocalCredentials)
                    {
                        UIManager.Instance.AddScreen(Screens.Login.Instance);
                    }
                    else
                    {
                        Screens.Login.Instance.LoginFailed(req.downloadHandler.text);
                    }
                }
                else
                {
                    Credentials receivedCreds = JsonUtility.FromJson <Credentials>(req.downloadHandler.text);
                    credentials.token = Token = receivedCreds.token;
                    credentials.id    = receivedCreds.id;

                    Screens.Login.Instance.LoginSuccess();

                    OnLoginSuccess?.Invoke(credentials);
                    StartCoroutine(GetPlayerDatas());
                }
            }
        }
Exemple #6
0
    private void RegisterAuthenticate(LoginResult result)
    {
        if (OnLogMessage != null)
        {
            OnLogMessage.Invoke("RegisterAuthenticate Start");
        }
        PlayFabClientAPI.RegisterPlayFabUser(new RegisterPlayFabUserRequest()
        {
            Username = Email.Replace("@", "").Replace(".", ""), //Because it is required & Unique and not supplied by User.
            Email    = Email,
            Password = Password,
        }, (registerResult) =>
        {
            if (OnLoginSuccess != null)
            {
                //Store identity and session
                _playFabId     = registerResult.PlayFabId;
                _sessionTicket = registerResult.SessionTicket;

                //Report login result back to subscriber.
                OnLoginSuccess.Invoke();
                if (OnLogMessage != null)
                {
                    OnLogMessage.Invoke("RegisterAuthenticate Success");
                }
                //AuthenticateEmailPassword();
            }
        }, (Registererror) =>
        {
            if (OnLogMessage != null)
            {
                OnLogMessage.Invoke("RegisterAuthenticate Fail");
            }
        });
    }
Exemple #7
0
 public void OnLoginSuccessCallback()
 {
     if (OnLoginSuccess != null)
     {
         OnLoginSuccess.Invoke();
     }
 }
        private async void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var url      = ServerTextBox.Text;
            var username = UserNameTextBox.Text;
            var password = PasswordTextBox.Password;

            var success = await service.Socialcast.VerifyCredentialsAsync(url, username, password);

            if (success)
            {
                service.Settings.AuthUser = new AuthUser
                {
                    ServiceUrl = url,
                    Email      = username,
                    Password   = password
                };

                var userInfo = await service.Socialcast.GetUserInfo();

                if (!userInfo.HasError())
                {
                    service.Settings.AuthUser.Id = userInfo.Value.user.id;

                    if (OnLoginSuccess != null)
                    {
                        OnLoginSuccess.Invoke(this, new EventArgs());
                    }

                    return;
                }
            }

            service.Settings.AuthUser = null;
            MessageBox.Show("Authentication failed");
        }
      private async void Window_Loaded(object sender, RoutedEventArgs e)
      {
          var browser = new EmbeddedBrowser(webBrowser, _clientOptions.RedirectUri);

          _clientOptions.Browser = browser;

          var client = new HelseIdClient(_clientOptions);

          var result = await client.Login();

          if (result.IsError)
          {
              OnLoginError?.Invoke(this, new LoginEventArgs()
                {
                    Response = result
                });
          }
          else
          {
              OnLoginSuccess?.Invoke(this, new LoginEventArgs()
                {
                    Response      = result,
                    AccessToken   = result.AccessToken,
                    IdentityToken = result.IdentityToken,
                    IsError       = result.IsError,
                    Error         = result.Error
                });
          }
      }
        public void Login(string username, string password, OnLoginSuccess onSuccess, OnLoginFailure onFailure)
        {
            var request = new LoginWithPlayFabRequest
            {
                Username = username,
                Password = password,
                InfoRequestParameters = new GetPlayerCombinedInfoRequestParams {
                    GetUserAccountInfo = true
                }
            };

            PlayFabClientAPI.LoginWithPlayFab(request,
                                              result =>
            {
                player.Name = result.InfoResultPayload.AccountInfo.Username;
                player.Id   = result.PlayFabId;

                mode = GameSessionMode.Online;
                onSuccess.Invoke(player);
            },
                                              error =>
            {
                onFailure.Invoke(error.GenerateErrorReport());
            });
        }
Exemple #11
0
 internal void InvokeLoginSuccess(LoginResult loginResult)
 {
     if (OnLoginSuccess != null)
     {
         OnLoginSuccess.Invoke(loginResult);
     }
 }
    /// <summary>
    /// Register a user with an Email & Password
    /// Note: We are not using the RegisterPlayFab API
    /// </summary>
    private void AddAccountAndPassword()
    {
        //Any time we attempt to register a player, first silently authenticate the player.
        //This will retain the players True Origination (Android, iOS, Desktop)
        SilentlyAuthenticate((result) => {
            if (result == null)
            {
                //something went wrong with Silent Authentication, Check the debug console.
                OnPlayFabError.Invoke(new PlayFabError()
                {
                    Error        = PlayFabErrorCode.UnknownError,
                    ErrorMessage = "Silent Authentication by Device failed"
                });
            }

            //Note: If silent auth is success, which is should always be and the following
            //below code fails because of some error returned by the server ( like invalid email or bad password )
            //this is okay, because the next attempt will still use the same silent account that was already created.

            //Now add our username & password.
            PlayFabClientAPI.AddUsernamePassword(new AddUsernamePasswordRequest()
            {
                Username = !string.IsNullOrEmpty(Username) ? Username : result.PlayFabId, //Because it is required & Unique and not supplied by User.
                Email    = Email,
                Password = Password,
            }, (addResult) => {
                if (OnLoginSuccess != null)
                {
                    //Store identity and session
                    _playFabId     = result.PlayFabId;
                    _sessionTicket = result.SessionTicket;

                    //If they opted to be remembered on next login.
                    if (RememberMe)
                    {
                        //Generate a new Guid
                        RememberMeId = Guid.NewGuid().ToString();
                        //Fire and forget, but link the custom ID to this PlayFab Account.
                        PlayFabClientAPI.LinkCustomID(new LinkCustomIDRequest()
                        {
                            CustomId  = RememberMeId,
                            ForceLink = ForceLink
                        }, null, null);
                    }

                    //Override the auth type to ensure next login is using this auth type.
                    AuthType = Authtypes.EmailAndPassword;

                    //Report login result back to subscriber.
                    OnLoginSuccess.Invoke(result);
                }
            }, (error) => {
                if (OnPlayFabError != null)
                {
                    //Report error result back to subscriber
                    OnPlayFabError.Invoke(error);
                }
            });
        });
    }
Exemple #13
0
        public void Register(string username, string email, string password, OnLoginSuccess onSuccess, OnLoginFailure onFailure)
        {
            var request = new RegisterPlayFabUserRequest
            {
                Username = username,
                Email    = email,
                Password = password,
                InfoRequestParameters = new GetPlayerCombinedInfoRequestParams
                {
                    GetUserAccountInfo = true
                }
            };

            PlayFabClientAPI.RegisterPlayFabUser(request,
                                                 result =>
            {
                player.Username = result.Username;
                player.UserId   = result.PlayFabId;
                onSuccess.Invoke(player);
            },
                                                 error =>
            {
                onFailure.Invoke(error.GenerateErrorReport());
            });
        }
Exemple #14
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     if (await ViewModel.Login(Password.Password))
     {
         Password.Password = string.Empty; // password is in plain text - do not leave it in memory
         OnLoginSuccess?.Invoke(this, new LoginEventArgs(ViewModel.Token));
     }
 }
        private async Task BtnLogin_TouchUpInside(object sender)
        {
            //Validate our Username & Password.
            //This is usually a web service call.
            try
            {
                var bounds = UIScreen.MainScreen.Bounds;

                // show the loading overlay on the UI thread using the correct orientation sizing
                _loadPop = new LoadingOverlay(bounds, "Logging you in..."); // using field from step 2
                View.Add(_loadPop);

                if (IsUserNameValid() && IsPasswordValid())
                {
                    username = UserNameTextView.Text.Trim();
                    password = PasswordTextView.Text.Trim();

                    //We have successfully authenticated a the user,
                    //Now fire our OnLoginSuccess Event.
                    _userModel = await _restActions.LoginUser(username, password);

                    if (_userModel != null)
                    {
                        UserSession.SetUserSession(_userModel);
                        if (UserSession.IsLoggedIn())
                        {
                            _loadPop.Hide();
                            OnLoginSuccess?.Invoke(sender, new EventArgs());
                        }
                        else
                        {
                            var message = "Unable to log you in, please try again";
                            if (_userModel.message != null)
                            {
                                message = _userModel.message;
                            }
                            _loadPop.Hide();
                            MessagingActions.ShowAlert("Unable to login", message);
                        }
                    }
                    else
                    {
                        _loadPop.Hide();
                        MessagingActions.ShowAlert("Login Error", "Incorrect user name or password");
                    }
                }
                else
                {
                    _loadPop.Hide();
                    MessagingActions.ShowAlert("Unable to login", "Incorrect user name or password");
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                _loadPop.Hide(0); //hide immediatelly
            }
        }
 private void LoginSuccess(LoginResult result)
 {
     _playFabId     = result.PlayFabId;
     _sessionTicket = result.SessionTicket;
     if (OnLoginSuccess != null)
     {
         OnLoginSuccess.Invoke(result);
     }
 }
        /// <summary>
        /// Completes synchronously, cannot fail
        /// </summary>
        public void LoginOffline(OnLoginSuccess onSuccess)
        {
            player = new PlayerInfo
            {
                Name = "Peasant",
                Id   = "N/A"
            };

            mode = GameSessionMode.Offline;
            onSuccess.Invoke(player);
        }
Exemple #18
0
    public void SilentlyAuthenticate(System.Action <LoginResult> callback = null)
    {
        if (OnLogMessage != null)
        {
            OnLogMessage.Invoke("SilentlyAuthenticate Start");
        }
        PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest()
        {
            TitleId               = PlayFabSettings.TitleId,
            CustomId              = PlayFabSettings.DeviceUniqueIdentifier,
            CreateAccount         = true,
            InfoRequestParameters = InfoRequestParams
        }, (result) =>
        {
            //Store Identity and session
            _playFabId     = result.PlayFabId;
            _sessionTicket = result.SessionTicket;

            //check if we want to get this callback directly or send to event subscribers.
            if (callback == null && OnLoginSuccess != null)
            {
                //report login result back to the subscriber
                OnLoginSuccess.Invoke();
            }
            else if (callback != null)
            {
                //report login result back to the caller
                callback.Invoke(result);
            }
            if (OnLogMessage != null)
            {
                OnLogMessage.Invoke("SilentlyAuthenticate Success");
            }
        }, (error) =>
        {
            if (OnLogMessage != null)
            {
                OnLogMessage.Invoke("PlayFab authenticating using Custom ID...");
            }
            //report errro back to the subscriber
            if (callback == null && OnPlayFabError != null)
            {
                if (OnLogMessage != null)
                {
                    OnLogMessage.Invoke("SilentlyAuthenticate Fail");
                }
            }
            else
            {
                //make sure the loop completes, callback with null
                callback.Invoke(null);
            }
        });
    }
        private void LogInButton_Click(object sender, EventArgs e)
        {
            try
            {
                controller.LogIn(UsernameInput.Text, PasswordInput.Text);

                OnLoginSuccess?.Invoke(this, EventArgs.Empty);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Invalid username/password combination. Try again.");
            }
        }
        public async Task DoLoginAsync()
        {
            try
            {
                User = await ApiClient.GetAsync <User>("login");

                LastError = null;
                JSRuntime.CustomLog($"User created, content: {System.Text.Json.JsonSerializer.Serialize(User)}");
                OnLoginSuccess.Invoke(null, null);
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
            }
        }
Exemple #21
0
 private void LoginResult <T>(PlayFabResult <T> result) where T : PlayFabResultCommon
 {
     if (null != result.Error)
     {
         //report error back to subscriber
         Logout();
         OnPlayFabError?.Invoke(result.Error);
     }
     else
     {
         //report login result back to subscriber
         OnLoginSuccess?.Invoke(new LoginResult
         {
         });
     }
 }
Exemple #22
0
 private void ConnectedCallback(SteamClient.ConnectedCallback connected)
 {
     Log.Info(" Done!");
     bConnecting = false;
     bConnected  = true;
     if (!authenticatedUser)
     {
         Log.Info("Logging anonymously into Steam3...");
         steamUser.LogOnAnonymous();
     }
     else
     {
         Log.Info("Logging '{0}' into Steam3...", logonDetails.Username);
         steamUser.LogOn(logonDetails);
         LoginSuccessHandlers?.Invoke();
     }
 }
Exemple #23
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            lblError.Visible = false;

            var pass  = StringCipher.Decrypt(Properties.Settings.Default.AUTH_PASS);
            var login = StringCipher.Decrypt(Properties.Settings.Default.AUTH_LOGIN);

            if (login.Trim() != string.Empty && pass.Trim() != string.Empty && txtLogin.Text.Trim().Equals(login) && txtPassword.Text.Equals(pass))
            {
                OnLoginSuccess?.Invoke();
                Close();
            }
            else
            {
                lblError.Visible = true;
            }
        }
Exemple #24
0
        private void LoginResult(PlayFabResult <LoginResult> result)
        {
            if (null != result.Error)
            {
                //report error back to subscriber
                Logout();
                OnPlayFabError?.Invoke(result.Error);
            }
            else
            {
                //Store identity and session
                PlayFabId     = result.Result.PlayFabId;
                SessionTicket = result.Result.SessionTicket;

                //report login result back to subscriber
                OnLoginSuccess?.Invoke(result.Result);
            }
        }
Exemple #25
0
    private void AddGoogleAccount(System.Action <LoginResult> callback = null)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        Debug.Log("Server Auth Code: " + AuthCode);

        PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
        {
            TitleId        = PlayFabSettings.TitleId,
            ServerAuthCode = AuthCode,
            CreateAccount  = true
        }, (result) =>
        {
            //Store Identity and session
            _playFabId     = result.PlayFabId;
            _sessionTicket = result.SessionTicket;

            //check if we want to get this callback directly or send to event subscribers.
            if (callback == null && OnLoginSuccess != null)
            {
                //report login result back to the subscriber
                OnLoginSuccess.Invoke(result);
            }
            else if (callback != null)
            {
                //report login result back to the caller
                callback.Invoke(result);
            }
        }, error =>
        {
            //report errro back to the subscriber
            if (callback == null && OnPlayFabError != null)
            {
                OnPlayFabError.Invoke(error);
            }
            else
            {
                //make sure the loop completes, callback with null
                callback.Invoke(null);
                //Output what went wrong to the console.
                Debug.LogError(error.GenerateErrorReport());
            }
        });
#endif
    }
Exemple #26
0
        public void OnCompleted(JSONObject p0, GraphResponse p1)
        {
            var id         = string.Empty;
            var first_name = string.Empty;
            var email      = string.Empty;
            var last_name  = string.Empty;
            var pictureUrl = string.Empty;

            if (p0.Has("id"))
            {
                id = p0.GetString("id");
            }

            if (p0.Has("first_name"))
            {
                first_name = p0.GetString("first_name");
            }

            if (p0.Has("email"))
            {
                email = p0.GetString("email");
            }

            if (p0.Has("last_name"))
            {
                last_name = p0.GetString("last_name");
            }

            if (p0.Has("picture"))
            {
                var p2 = p0.GetJSONObject("picture");
                if (p2.Has("data"))
                {
                    var p3 = p2.GetJSONObject("data");
                    if (p3.Has("url"))
                    {
                        pictureUrl = p3.GetString("url");
                    }
                }
            }

            User = new FacebookUser(id, AccessToken.CurrentAccessToken.Token, first_name, last_name, email, pictureUrl);
            OnLoginSuccess?.Invoke(User);
        }
Exemple #27
0
    public void AuthenticateEmailPassword()
    {
        if (OnLogMessage != null)
        {
            OnLogMessage.Invoke("AuthenticateEmailPassword Start");
        }
        //We have not opted for remember me in a previous session, so now we have to login the user with email & password.
        PlayFabClientAPI.LoginWithEmailAddress(new LoginWithEmailAddressRequest()
        {
            TitleId  = PlayFabSettings.TitleId,
            Email    = Email,
            Password = Password,
            InfoRequestParameters = InfoRequestParams
        }, (result) =>
        {
            //store identity and session
            _playFabId     = result.PlayFabId;
            _sessionTicket = result.SessionTicket;

            if (OnLoginSuccess != null)
            {
                //report login result back to subscriber
                OnLoginSuccess.Invoke();
                if (OnLogMessage != null)
                {
                    OnLogMessage.Invoke("AuthenticateEmailPassword Success");
                }
            }
        }, (error) =>
        {
            if (OnPlayFabError != null)
            {
                if (OnLogMessage != null)
                {
                    OnLogMessage.Invoke("AuthenticateEmailPassword Fail");
                }
            }
            if (error.Error == PlayFabErrorCode.AccountNotFound)
            {
                AddAccountAndPassword();
            }
        });
    }
Exemple #28
0
 public void OnLoginResponse()
 {
     if (!FB.IsLoggedIn)
     {
         Debug.Log("Login fail");
         if (OnLoginFail != null)
         {
             OnLoginFail.Invoke();
         }
     }
     else
     {
         Debug.Log("Login success");
         if (OnLoginSuccess != null)
         {
             OnLoginSuccess.Invoke();
             OnLoginSuccess -= OnLoginSuccess;
         }
     }
 }
Exemple #29
0
    async void Start()
    {
        PlayFabSettings.staticSettings.TitleId = "A80F6";

        var request = new LoginWithCustomIDRequest
        {
            CustomId      = "GettingStartedGuide",
            CreateAccount = true,
        };
        var result = await PlayFabClientAPI.LoginWithCustomIDAsync(request);

        if (result.Error != null)
        {
            Debug.Log(result.Error.GenerateErrorReport());
        }
        else
        {
            OnLoginSuccess?.Invoke(result.Result);
        }
    }
    private void AuthenticateFacebook()
    {
#if FACEBOOK
        if (FB.IsInitialized && FB.IsLoggedIn && !string.IsNullOrEmpty(AuthTicket))
        {
            PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest()
            {
                TitleId               = PlayFabSettings.TitleId,
                AccessToken           = AuthTicket,
                CreateAccount         = true,
                InfoRequestParameters = InfoRequestParams
            }, (result) =>
            {
                //Store Identity and session
                _playFabId     = result.PlayFabId;
                _sessionTicket = result.SessionTicket;

                //check if we want to get this callback directly or send to event subscribers.
                if (OnLoginSuccess != null)
                {
                    //report login result back to the subscriber
                    OnLoginSuccess.Invoke(result);
                }
            }, (error) =>
            {
                //report errro back to the subscriber
                if (OnPlayFabError != null)
                {
                    OnPlayFabError.Invoke(error);
                }
            });
        }
        else
        {
            if (OnDisplayAuthentication != null)
            {
                OnDisplayAuthentication.Invoke();
            }
        }
#endif
    }