Example #1
0
        public User Authenticate(UserAuthenticationRequest request)
        {
            User user = UserRepository.GetUser(request.Username);

            if (user == null || !PasswordManager.ComparePassword(request.Password, user.Password))
            {
                return(null);
            }
            if (!user.LoggedIn)
            {
                user.LoggedIn = true;
                UserRepository.Update(user);
            }
            return(GenerateToken(user));
        }