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.
        /// Whether to check lifetime of token.
        /// The info of the token.
        /// Thrown when  is null.
        /// Thrown when the token is not valid for reasons other than expired.
        /// Thrown when  is true and the token is expired.
        Task ValidateTokenAsync(string token, bool checkLifetime = true);
        /// 
        /// 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);
    }
}