Пример #1
0
        public async Task <ActionResult <AuthenticationResult> > Authenticate([FromBody] AuthenticationParameters parameters, CancellationToken cancellationToken)
        {
            var user = await _userRepository.GetByUsernameAndPassword(parameters.Username, parameters.Password, cancellationToken);

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

            var accessToken = _jwtGenerator.Generator(user);

            return(new AuthenticationResult {
                AccessToken = accessToken
            });
        }