コード例 #1
0
        public async Task <LoginCommandResult> Handle(LoginCommand request, CancellationToken cancellationToken)
        {
            User user = await _userAuthService.AuthenticateOrFail(request.UserQuery, request.Password);

            var role  = _roleService.GetRoleByAdminStatus(user.IsAdmin);
            var token = _authTokenGenerator.GenerateToken(user.Id, role);

            return(new LoginCommandResult
            {
                FirstName = user.FirstName,
                LastName = user.LastName,
                Username = user.Username,
                Email = user.Email,
                Token = token
            });
        }