コード例 #1
0
        public async Task <AuthenticateResponse> LoginAsync(AuthenticateRequest model)
        {
            var user = await userRepository.AuthenticateUserAsync(model.OwnerId, model.Username, model.Password);

            if (user == null)
            {
                return(null);
            }

            // authentication successful so generate jwt token
            var userDto = userToUserDtoHydrator.Hydrate(user);
            var token   = await generateJwtToken(userDto);

            await cachingService.CreateUserSession(model.OwnerId, userDto.UserName, token);

            return(new AuthenticateResponse(userDto, token));
        }