Ejemplo n.º 1
0
        public async Task <AuthResult> SignIn(UserAuth user)
        {
            var userForSignIn = await _userStorage.FindByName(user.Login);

            if (userForSignIn != null)
            {
                if (await _userStorage.CheckPassword(userForSignIn, user.Password))
                {
                    return(GenerateJwtToken(userForSignIn));
                }

                return(new AuthResult
                {
                    Success = false,
                    ErrorMessage = "Your password is invalid"
                });
            }

            return(new AuthResult
            {
                Success = false,
                ErrorMessage = "User with this login dosen't exist"
            });
        }