コード例 #1
0
        public LoginResponse Login(LoginModel loginModel)
        {
            string hashedPassword = _passwordGenerator.GenerateHashedPassword(loginModel.Password);

            var loginUser = _unitOfWork.UserRepository.Get(user => user.Email == loginModel.Email).FirstOrDefault();

            if (loginUser != null && _passwordGenerator.Verify(loginUser.Password, loginModel.Password))
            {
                return(new LoginResponse
                {
                    Id = loginUser.Id,
                    FullName = loginUser.FullName,
                    Email = loginUser.Email,
                    AccessToken = _accessTokenGenerator.GenerateAccessToken(loginUser)
                });
            }
            return(null);
        }