diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-01 22:32:40 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-01 22:32:40 +0800 |
commit | 9aeca6f6adf1a20d85e1fdbc8bdc8dfb35be28c1 (patch) | |
tree | abbdb97d24c2e6d7c32433887643676637011720 /Timeline/Services/UserService.cs | |
parent | ee506e832e19e84cba2f9cf1c2b0172ca3e092b6 (diff) | |
download | timeline-9aeca6f6adf1a20d85e1fdbc8bdc8dfb35be28c1.tar.gz timeline-9aeca6f6adf1a20d85e1fdbc8bdc8dfb35be28c1.tar.bz2 timeline-9aeca6f6adf1a20d85e1fdbc8bdc8dfb35be28c1.zip |
Add token expire time.
Diffstat (limited to 'Timeline/Services/UserService.cs')
-rw-r--r-- | Timeline/Services/UserService.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs index 3164a645..328dbff0 100644 --- a/Timeline/Services/UserService.cs +++ b/Timeline/Services/UserService.cs @@ -58,11 +58,12 @@ namespace Timeline.Services /// </summary> /// <param name="username">The username of the user to anthenticate.</param> /// <param name="password">The password of the user to anthenticate.</param> + /// <param name="expires">The expired time point. Null then use default. See <see cref="JwtService.GenerateJwtToken(TokenInfo, DateTime?)"/> for what is default.</param> /// <returns>An <see cref="CreateTokenResult"/> containing the created token and user info.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="username"/> or <paramref name="password"/> is null.</exception> /// <exception cref="UserNotExistException">Thrown when the user with given username does not exist.</exception> /// <exception cref="BadPasswordException">Thrown when password is wrong.</exception> - Task<CreateTokenResult> CreateToken(string username, string password); + Task<CreateTokenResult> CreateToken(string username, string password, DateTime? expires = null); /// <summary> /// Verify the given token. @@ -170,7 +171,7 @@ namespace Timeline.Services _memoryCache.Remove(GenerateCacheKeyByUserId(id)); } - public async Task<CreateTokenResult> CreateToken(string username, string password) + public async Task<CreateTokenResult> CreateToken(string username, string password, DateTime? expires) { if (username == null) throw new ArgumentNullException(nameof(username)); @@ -198,7 +199,7 @@ namespace Timeline.Services { Id = user.Id, Version = user.Version - }); + }, expires); return new CreateTokenResult { Token = token, |