예제 #1
0
        public async Task <IActionResult> LoginUser([FromBody] UserLogin login, CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(ModelState)));
            }

            var result = await _accountsService.SignInUser(login.UserName, login.Password);

            if (!result.Succeeded)
            {
                return(Unauthorized());
            }

            var appUser = _accountsService.GetUserByUserName(login.UserName);

            return(Ok(_accountsService.GenerateJwtToken(appUser)));
        }