コード例 #1
0
        public string LoginAccount(LoginAttemptModel account)
        {
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    _authNService._userEmail = account.Email;
                    var authNSuccess = _authNService.Authenticate(account.Password);
                    if (authNSuccess)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    var handler = new ErrorController();
                    handler.Handle(e);
                }
                if (i == 2)
                {
                    throw new Exception("Failed to Authenticate User");
                }
            }

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    var user = _authNService.FindUser(account);
                    if (user is object)
                    {
                        return(_authService.GenerateJWT(user));
                    }
                }
                catch (Exception e)
                {
                    var handler = new ErrorController();
                    handler.Handle(e);
                }
            }


            throw new Exception("Failed to Login");
        }