From 9aeca6f6adf1a20d85e1fdbc8bdc8dfb35be28c1 Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Thu, 1 Aug 2019 22:32:40 +0800 Subject: Add token expire time. --- Timeline/Services/UserService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Timeline/Services/UserService.cs') 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 /// /// The username of the user to anthenticate. /// The password of the user to anthenticate. + /// The expired time point. Null then use default. See for what is default. /// An containing the created token and user info. /// Thrown when or is null. /// Thrown when the user with given username does not exist. /// Thrown when password is wrong. - Task CreateToken(string username, string password); + Task CreateToken(string username, string password, DateTime? expires = null); /// /// Verify the given token. @@ -170,7 +171,7 @@ namespace Timeline.Services _memoryCache.Remove(GenerateCacheKeyByUserId(id)); } - public async Task CreateToken(string username, string password) + public async Task 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, -- cgit v1.2.3