Beispiel #1
0
        public async Task <IActionResult> LoginAsync(LoginRequest loginRequest)
        {
            LoginModel loginModel = loginRequest.Adapt <LoginModel>();

            AuthorizationResultModel result = await _accountService.AuthorizeUserAsync(loginModel);

            if (result.ResultStatus == AuthorizationResultStatus.Ok)
            {
                AuthorizationResponse authorizationResponse = result.Adapt <AuthorizationResponse>();

                await HttpContext.SignInAsync(authorizationResponse);

                return(Ok(authorizationResponse));
            }

            return(Unauthorized("Incorrect login data"));
        }