private async Task ValidSubmit()
        {
            var loginCancelEventArgs = new LoginCancelEventArgs();
            await OnLoggingIn.InvokeAsync(loginCancelEventArgs);

            if (loginCancelEventArgs.Cancel)
            {
                Model.Password = string.Empty;
            }
            else
            {
                var authenticateEventArgs = new AuthenticateEventArgs();
                await OnAuthenticate.InvokeAsync(authenticateEventArgs);

                if (authenticateEventArgs.Authenticated)
                {
                    await OnLoggedIn.InvokeAsync(EventArgs.Empty);

                    if (!string.IsNullOrEmpty(DestinationPageUrl))
                    {
                        NavigationManager.NavigateTo(DestinationPageUrl);
                    }

                    ShowFailureText = false;
                }
                else
                {
                    await OnLoginError.InvokeAsync(EventArgs.Empty);

                    Model.Password  = string.Empty;
                    ShowFailureText = true;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Authenticate the user by the Auth Type that was defined.
        /// </summary>
        public async Task Authenticate()
        {
            switch (AuthType)
            {
            case AuthType.Silent:
            {
                OnLoggingIn?.Invoke();
                var platform = CrossDeviceInfo.Current.Platform;
                await SilentlyAuthenticate(platform).ConfigureAwait(false);
            }
            break;

            case AuthType.EmailAndPassword:
            {
                OnLoggingIn?.Invoke();
                await AuthenticateEmailPassword().ConfigureAwait(false);
            }
            break;

            case AuthType.RegisterPlayFabAccount:
            {
                OnLoggingIn?.Invoke();
                await AddAccountAndPassword().ConfigureAwait(false);
            }
            break;

            case AuthType.Facebook:
            {
                await AuthenticateFacebook().ConfigureAwait(false);
            }
            break;

            case AuthType.Google:
            {
                OnLoggingIn?.Invoke();
                await AuthenticateGooglePlayGames().ConfigureAwait(false);
            }
            break;

            default:
            {
                if (RememberMe)
                {
                    OnLoggingIn?.Invoke();
                    AuthType = AuthType.EmailAndPassword;
                    await AuthenticateEmailPassword().ConfigureAwait(false);
                }
                else
                {
                    OnDisplayAuthentication?.Invoke();
                }
            }
            break;
            }
        }
Пример #3
0
        private async Task AuthenticateFacebookUser(FacebookUser loggedInUser)
        {
            OnLoggingIn?.Invoke();

            //grab the auth ticket from that user
            AuthTicket = loggedInUser.Token;

            var result = await PlayFabClient.LoginWithFacebookAsync(new LoginWithFacebookRequest()
            {
                TitleId               = PlayFabSettings.staticSettings.TitleId,
                AccessToken           = AuthTicket,
                CreateAccount         = true,
                InfoRequestParameters = InfoRequestParams
            }).ConfigureAwait(false);

            LoginResult(result);
        }
Пример #4
0
        public async Task LinkFacebook()
        {
            //If there is no Facebook client, we can't do this
            if (null == Facebook)
            {
                Logout();
                OnPlayFabError?.Invoke(new PlayFabError()
                {
                    ErrorMessage = "No FacebookClient was detected",
                });
            }

            //Check if the user needs to log into Facebook
            if (!Facebook.LoggedIn || string.IsNullOrEmpty(AuthTicket))
            {
                //sign up for the logged in event
                Facebook.OnLoginSuccess -= OnFacebookLoggedIn;
                Facebook.OnLoginSuccess += OnFacebookLoggedIn;
                Facebook.OnLoginError   -= Facebook_OnLoginError;
                Facebook.OnLoginError   += Facebook_OnLoginError;

                //try to log in
                Facebook.Login();
            }
            else
            {
                OnLoggingIn?.Invoke();

                //grab the auth ticket from that user
                AuthTicket = Facebook.User.Token;

                var result = await PlayFabClient.LinkFacebookAccountAsync(new LinkFacebookAccountRequest()
                {
                    AccessToken = AuthTicket,
                }).ConfigureAwait(false);

                LoginResult(result);
            }
        }