Esempio n. 1
0
 public void SingOut(Action <SA_Result> callback)
 {
     SignInClient.RevokeAccess(() => {
         UpdatePlayerInfo(null);
         callback.Invoke(new SA_Result());
     });
 }
        public override void Test()
        {
            SignInClient.RevokeAccess(() => {
                //Now we need to make sure we can't Sing in siletly
                SilentSignIn((result) => {
                    if (result.IsSucceeded)
                    {
                        SetResult(SA_TestResult.WithError("User was able to do Silent SignIn after RevokeAccess"));
                    }
                    else
                    {
                        //InteractiveSignIn should work
                        InteractiveSignIn((InteractiveSignInResult) => {
                            SetAPIResult(InteractiveSignInResult);

                            if (InteractiveSignInResult.IsSucceeded)
                            {
                                var gamesClient = AN_Games.GetGamesClient();
                                gamesClient.SetViewForPopups(AN_MainActivity.Instance);

                                //optionally
                                gamesClient.SetGravityForPopups(AN_Gravity.TOP | AN_Gravity.CENTER_HORIZONTAL);
                            }
                        });
                    }
                });
            });
        }
Esempio n. 3
0
        public UM_AndroidSignInClient()
        {
            SA_MonoEvents.OnApplicationPause.AddSafeListener(this, (paused) => {
                if (!paused)
                {
                    //We do not want to do Silent SignIn on resume in case player not yet signed.
                    if (PlayerInfo.State == UM_PlayerState.SignedOut)
                    {
                        // In case it's not null, this means we are missng something, so we will do  Silent SignIn
                        // The case may happend because we sending fail event on propxy Activity Destory event.
                        // But propxy Activity Destory not always means that player is failed to log in.
                        // We have to send fail evennt on propxy Activity Destory, since if we not, in cases where google and our proxy
                        // activity both are destoryed, we will not get any event.
                        if (AN_GoogleSignIn.GetLastSignedInAccount() == null)
                        {
                            return;
                        }
                    }

                    //We need to perform Silent SignIn every time we back from pause
                    SignInClient.SilentSignIn((silentSignInResult) => {
                        if (silentSignInResult.IsSucceeded)
                        {
                            RetrivePlayer((result) => { });
                        }
                        else
                        {
                            //looks Like player singed out
                            UpdatePlayerInfo(null);
                        }
                    });
                }
            });
        }
 public override void Test()
 {
     SignInClient.SignOut(() => {
         //Now we need to make sure we can Sing in siletly
         SilentSignIn((result) => {
             SetAPIResult(result);
         });
     });
 }
Esempio n. 5
0
        private void StartSingInFlowternal(Action <SA_Result> callback)
        {
            AN_Logger.Log("UM_AndroidSignInClient, starting siglent sing-in");
            SignInClient.SilentSignIn((silentSignInResult) => {
                if (silentSignInResult.IsSucceeded)
                {
                    AN_Logger.Log("UM_AndroidSignInClient, siglent sing-in Succeeded");
                    RetrivePlayer(callback);
                }
                else
                {
                    AN_Logger.Log("UM_AndroidSignInClient, siglent sing-in Failed");
                    AN_Logger.Log("UM_AndroidSignInClient, starting interactive sing-in");
                    SignInClient.SignIn((interactiveSignInResult) => {
                        AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in completed");
                        if (interactiveSignInResult.IsSucceeded)
                        {
                            AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in succeeded");
                            RetrivePlayer(callback);
                        }
                        else
                        {
                            AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in failed");
                            int errorCode = interactiveSignInResult.Error.Code;
                            switch (errorCode)
                            {
                            //Retry may solve the issue
                            case (int)AN_CommonStatusCodes.NETWORK_ERROR:

                            //in some cases it may cause a loop
                            //case (int)AN_CommonStatusCodes.INTERNAL_ERROR:
                            case (int)AN_CommonStatusCodes.FAILED_ACTIVITY_ERROR:
                                //Let's see if we tried to do it before
                                if (m_resolvedErrors.Contains(errorCode))
                                {
                                    AN_Logger.Log("UM_AndroidSignInClient, sending fail result");
                                    callback.Invoke(new SA_Result(interactiveSignInResult.Error));
                                }
                                else
                                {
                                    //Nope, this is new one, let's try to resolve it
                                    AN_Logger.Log("Trying to resolved failed sigin-in result with code: " + errorCode);
                                    StartSingInFlowternal(callback);
                                }
                                break;

                            default:
                                AN_Logger.Log("UM_AndroidSignInClient, sending fail result");
                                callback.Invoke(new SA_Result(interactiveSignInResult.Error));
                                break;
                            }
                        }
                    });
                }
            });
        }
Esempio n. 6
0
        private void StartSingInFlowInternal(Action <SA_Result> callback)
        {
            AN_Logger.Log("UM_AndroidSignInClient, starting silent sing-in");
            SignInClient.SilentSignIn(silentSignInResult =>
            {
                if (silentSignInResult.IsSucceeded)
                {
                    AN_Logger.Log("UM_AndroidSignInClient, silent sing-in Succeeded");
                    RetrievePlayer(callback);
                }
                else
                {
                    AN_Logger.Log("UM_AndroidSignInClient, silent sing-in Failed");
                    AN_Logger.Log("UM_AndroidSignInClient, starting interactive sing-in");
                    SignInClient.SignIn(interactiveSignInResult =>
                    {
                        AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in completed");
                        if (interactiveSignInResult.IsSucceeded)
                        {
                            AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in succeeded");
                            RetrievePlayer(callback);
                        }
                        else
                        {
                            AN_Logger.Log("UM_AndroidSignInClient, interactive sing-in failed");
                            var errorCode = interactiveSignInResult.Error.Code;
                            switch (errorCode)
                            {
                            //Retry may solve the issue
                            case (int)AN_CommonStatusCodes.NETWORK_ERROR:
                            case (int)AN_GoogleSignInStatusCodes.SIGN_IN_CURRENTLY_IN_PROGRESS:
                                m_ResolvedErrors.Add(errorCode);
                                //Let's see if we tried to do it before
                                if (m_ResolvedErrors.Contains(errorCode))
                                {
                                    AN_Logger.Log("UM_AndroidSignInClient, sending fail result");
                                    callback.Invoke(new SA_Result(interactiveSignInResult.Error));
                                }
                                else
                                {
                                    //Nope, this is new one, let's try to resolve it
                                    AN_Logger.Log("Trying to resolved failed sigin-in result with code: " + errorCode);
                                    StartSingInFlowInternal(callback);
                                }
                                break;

                            default:
                                AN_Logger.Log("UM_AndroidSignInClient, sending fail result");
                                callback.Invoke(new SA_Result(interactiveSignInResult.Error));
                                break;
                            }
                        }
                    });
                }
            });
        }
Esempio n. 7
0
 protected void SilentSignIn(Action <AN_GoogleSignInResult> result)
 {
     AN_Logger.Log("Let's try Silent SignIn first");
     SignInClient.SilentSignIn((signInResult) => {
         if (signInResult.IsSucceeded)
         {
             PrintInfo(signInResult.Account);
         }
         result.Invoke(signInResult);
     });
 }
Esempio n. 8
0
 protected void InteractiveSignIn(Action <AN_GoogleSignInResult> result)
 {
     AN_Logger.Log("Starting the Interactive Sign in flow");
     SignInClient.SignIn((signInResult) => {
         AN_Logger.Log("Sign In StatusCode: " + signInResult.StatusCode);
         if (signInResult.IsSucceeded)
         {
             PrintInfo(signInResult.Account);
         }
         result.Invoke(signInResult);
     });
 }
Esempio n. 9
0
 public override void Test()
 {
     if (AN_GoogleSignIn.GetLastSignedInAccount() != null)
     {
         SignInClient.SignOut(() => {
             SignIn();
         });
     }
     else
     {
         SignIn();
     }
 }
        public async Task <IActionResult> Login(string email, string password)
        {
            try
            {
                var user = await IdentityReader.AuthenticateAsync(email, password);

                await SignInClient.SignInAsync(HttpContext, user, true);

                return(Redirect("/"));
            }
            catch (AuthenticationException)
            {
                return(Content("Invalid credentials!"));
            }
        }
Esempio n. 11
0
        private async Task DoSignOut()
        {
            if (await SignInClient.SignOutAsync())
            {
                _authState = await AuthStateProvider.GetAuthenticationStateAsync();

                StateHasChanged();

                if (AuthStateProvider is IHostEnvironmentAuthenticationStateProvider heasp)
                {
                    _authState = new AuthenticationState(await SignInClient.CreateClaimsPrincipal());
                    heasp.SetAuthenticationState(Task.FromResult(_authState));
                }

                Nav.NavigateTo("/");
                return;
            }
            _customValidator.Add("Unable to sign out.");
        }
 public SignInClientViewModel(SignInClient client)
 {
     this.client = client;
     results     = new ObservableCollection <SignInResultViewModel>();
 }
Esempio n. 13
0
 public SignInClientViewModel(SignInClient client)
 {
     this.client   = client;
     signInCommand = new RelayCommand(async p => await SignIn(p), CanSignIn);
 }