Beispiel #1
0
        public override async Task <LoginResponse> Login(LoginRequest request, ServerCallContext context)
        {
            var tokenData = await _jwtTokenService.CreateAuthenticationAsync(request.User, request.Password);

            return(new LoginResponse()
            {
                AccessToken = tokenData.AccessToken,
                RefreshToken = tokenData.RefreshToken,
                InvalidCredentials = tokenData.InvalidCredentials
            });
        }
Beispiel #2
0
        public async Task <ActionResult <JwtAuthenticationResult> > Authenticate([FromBody] JwtLoginCredentials model)
        {
            if (model == null)
            {
                return(StatusCode((int)HttpStatusCode.ExpectationFailed));
            }

            _logger.LogInformation("User {Name} is authenticating", model.User);
            var authentication = await _jwtTokenService.CreateAuthenticationAsync(model.User, model.Password);

            if (authentication.InvalidCredentials)
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized));
            }

            return(Json(authentication));
        }