Ejemplo n.º 1
0
        public static void HandleExceptions(Exception e, int _clientid, string authenticationScene)
        {
            Console.WriteLine("SignInClients.cs | My User Authentication Failed");
            switch (e.GetType().ToString())
            {
            case "Amazon.CognitoIdentityProvider.Model.PasswordResetRequiredException":
                Console.WriteLine("SignInClients.cs | Exception | Handle Reset Password");    // TO DO
                ServerSend.AuthenticationStatus(_clientid, Constants.AUTHENTICATION_KO_RESET_PWD_REQUIRED);
                break;

            case "Amazon.CognitoIdentityProvider.Model.NotAuthorizedException":
                if (authenticationScene == Constants.SCENE_AUTHENTICATION)
                {
                    Console.WriteLine("SignInClients.cs | Exception | Unknown Username or password.");
                    ServerSend.AuthenticationStatus(_clientid, Constants.AUTHENTICATION_KO);
                }
                else if (authenticationScene == Constants.SCENE_REDEFINE_PWD)
                {
                    Console.WriteLine("SignInClients.cs | Exception | Unknown Username or password.");
                    ServerSend.AuthenticationStatus(_clientid, Constants.AUTHENTICATION_REDEFINE_PWD_KO);
                }
                break;

            case "Amazon.CognitoIdentityProvider.Model.UserNotConfirmedException":
                Console.WriteLine("SignInClients.cs | Exception | Need User Email Confirmation.");
                ServerSend.AuthenticationStatus(_clientid, Constants.AUTHENTICATION_USER_CONFIRMED_KO);
                break;

            default:
                Console.WriteLine("SignInClients.cs | Unknown Exception | " + e.GetType().ToString() + " | " + e);
                ServerSend.AuthenticationStatus(_clientid, Constants.AUTHENTICATION_KO);
                break;
            }
        }
Ejemplo n.º 2
0
 public async void SignInToCognito(string _username, string _password)
 {
     //Console.WriteLine("SignUpToCognito Return :"+_signUpReturn);
     if (SecurityCheck.CheckUserPattern(_username))
     {
         if (SecurityCheck.CheckPasswordPattern(_password))
         {
             // This will SET a UserCognito with Valid Tokens on my Client.
             // And send the tokens to the Client who has Sign In
             //Server.clients[_fromClient].player.
             myUser = new CognitoUser(_username, Constants.CLIENTAPP_ID, Server.cognitoManagerServer.userPool, Server.cognitoManagerServer.provider, Constants.NeokySecret);
             await SignInClients.SignInClientToCognito(_username, _password, id);
         }
         else
         {
             ServerSend.AuthenticationStatus(id, Constants.AUTHENTIFICATION_FORMAT_PASSWORD_KO);
         }
     }
     else
     {
         ServerSend.AuthenticationStatus(id, Constants.AUTHENTIFICATION_FORMAT_USERNAME_KO);
     }
 }