public async Task <IActionResult> LoginAsync([FromBody] UserModel user) { try { var existUser = await _authenticationModule.LoginAsync(user.userlogin_id, user.userlogin_pwd); CheckUserIsNotNull(existUser); var requestAt = DateTime.Now; var expiresIn = requestAt + TokenAuthenticationOptions.ExpiresSpan; var userLogin = new UserLogin { LoginDate = requestAt, ExpireDate = expiresIn, Token = CreateToken(existUser, expiresIn), Type = UserLoginType.Bearer, Status = "Success", User = existUser }; return(Ok(new { RequertAt = userLogin.LoginDate, ExpiresIn = TokenAuthenticationOptions.ExpiresSpan.TotalSeconds, ExpiresAt = userLogin.LoginDate.AddSeconds(TokenAuthenticationOptions.ExpiresSpan.TotalSeconds), TokeyType = TokenAuthenticationOptions.TokenType, AccessToken = userLogin.Token, User = new { userLogin.User.user_id, userLogin.User.user_name, userLogin.User.user_surname, userLogin.User.userlogin_id, } })); } catch (Exception e) { return(BadRequest(e.Message.ConvertExceptionToErrorInfo())); } }