Exemple #1
0
        public async Task <JsonWebToken> LoginAsync(string email, string password)
        {
            var user = await _userRepository.GetAsync(email);

            if (user == null)
            {
                throw new ActioException("invalid_credentials", "Invalid user credentials");
            }
            if (!user.ValidatePassword(password, _encrypter))
            {
                throw new ActioException("invalid_credentials",
                                         "Invalid user credentials");
            }
            return(_jwtHandler.Crete(user.Id));
        }