From db6629940e294b44d678e776ccce769a8ac715de Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Apr 2021 16:55:37 +0800 Subject: refactor: ... --- .../Timeline/Services/Token/IUserTokenManager.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 BackEnd/Timeline/Services/Token/IUserTokenManager.cs (limited to 'BackEnd/Timeline/Services/Token/IUserTokenManager.cs') diff --git a/BackEnd/Timeline/Services/Token/IUserTokenManager.cs b/BackEnd/Timeline/Services/Token/IUserTokenManager.cs new file mode 100644 index 00000000..c6eaa5b7 --- /dev/null +++ b/BackEnd/Timeline/Services/Token/IUserTokenManager.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading.Tasks; +using Timeline.Entities; +using Timeline.Services.User; + +namespace Timeline.Services.Token +{ + public interface IUserTokenManager + { + /// + /// Try to create a token for given username and password. + /// + /// The username. + /// The password. + /// The expire time of the token. + /// The created token and the user info. + /// Thrown when or is null. + /// Thrown when is of bad format. + /// Thrown when the user with does not exist. + /// Thrown when is wrong. + public Task CreateToken(string username, string password, DateTime? expireAt = null); + + /// + /// Verify a token and get the saved user info. This also check the database for existence of the user. + /// + /// The token. + /// The user stored in token. + /// Thrown when is null. + /// Thrown when the token is expired. + /// Thrown when the token is of bad version. + /// Thrown when the token is of bad format. + /// Thrown when the user specified by the token does not exist. Usually the user had been deleted after the token was issued. + public Task VerifyToken(string token); + } +} -- cgit v1.2.3