From da9139b7bab95f6e5ba5f4bb2d99011c2d6db03a Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 23 Mar 2022 21:30:14 +0800 Subject: … MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Timeline/Services/Token/IUserTokenService.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 BackEnd/Timeline/Services/Token/IUserTokenService.cs (limited to 'BackEnd/Timeline/Services/Token/IUserTokenService.cs') diff --git a/BackEnd/Timeline/Services/Token/IUserTokenService.cs b/BackEnd/Timeline/Services/Token/IUserTokenService.cs new file mode 100644 index 00000000..22fb0fb4 --- /dev/null +++ b/BackEnd/Timeline/Services/Token/IUserTokenService.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading.Tasks; + +namespace Timeline.Services.Token +{ + public interface IUserTokenService + { + /// + /// Create a token for a user. Please ensure the user id exists! + /// + /// The user id. + /// The expire time of the token. + /// Return the generated token. + Task CreateTokenAsync(long userId, DateTime? expireTime); + + /// + /// Verify a token and get the info of the token. + /// + /// The token to verify. + /// The info of the token. + /// Thrown when is null. + /// Thrown when the token is not valid for reasons other than expired. + /// Thrown when the token is expired. + Task ValidateTokenAsync(string token); + + /// + /// Revoke a token to make it no longer valid. + /// + /// The token to revoke. + /// Return true if a token is revoked. + /// Thrown when is null. + /// + /// This method returns true if a real token is revoked and returns false if the token is not valid. + /// If the token is expired, false is return. + /// + Task RevokeTokenAsync(string token); + + /// + /// Revoke all tokens of a user. + /// + /// User id of tokens. + /// Return the task. + Task RevokeAllTokenByUserIdAsync(long userId); + } +} -- cgit v1.2.3