public async Task <IActionResult> Login([FromBody] LoginMetaModel model) { // return token var result = await _authencationService.SignInAsync(model); if (!result.Succeeded) { return(BadRequest()); } return(Ok(await _tokenService.BuildTokenAsync(model))); }
public async Task <IActionResult> CreateToken([FromBody] LoginModel model) { return(await OnActionWorkAsync(async() => { User user = await _tokenService.AuthenticateAsync(model); if (user == null) { throw new UnauthorizedException(); } var tokenString = await _tokenService.BuildTokenAsync(user); return Ok(new { token = tokenString }); })); }