From 63573d7c988e0bc1b7e82eeea53ecc3678b0a2f5 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 11 Apr 2019 20:11:23 +0800 Subject: Change create token api. --- Timeline/Services/JwtService.cs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'Timeline/Services/JwtService.cs') diff --git a/Timeline/Services/JwtService.cs b/Timeline/Services/JwtService.cs index a01f3f2b..abdde908 100644 --- a/Timeline/Services/JwtService.cs +++ b/Timeline/Services/JwtService.cs @@ -11,12 +11,6 @@ using Timeline.Entities; namespace Timeline.Services { - public class TokenValidationResult - { - public bool IsValid { get; set; } - public UserInfo UserInfo { get; set; } - } - public interface IJwtService { /// @@ -30,17 +24,17 @@ namespace Timeline.Services /// /// Validate a JWT token. /// Return null is is null. - /// If token is invalid, return a with - /// set to false and - /// set to null. - /// If token is valid, return a with - /// set to true and - /// filled with the user info + /// If token is invalid, return a with + /// set to false and + /// set to null. + /// If token is valid, return a with + /// set to true and + /// filled with the user info /// in the token. /// /// The token string to validate. /// Null if is null. Or the result. - TokenValidationResult ValidateJwtToken(string token); + TokenValidationResponse ValidateJwtToken(string token); } @@ -86,7 +80,7 @@ namespace Timeline.Services } - public TokenValidationResult ValidateJwtToken(string token) + public TokenValidationResponse ValidateJwtToken(string token) { if (token == null) return null; @@ -114,7 +108,7 @@ namespace Timeline.Services Roles = identity.FindAll(identity.RoleClaimType).Select(claim => claim.Value).ToArray() }; - return new TokenValidationResult + return new TokenValidationResponse { IsValid = true, UserInfo = userInfo @@ -123,7 +117,7 @@ namespace Timeline.Services catch (Exception e) { _logger.LogInformation(e, "Token validation failed! Token is {} .", token); - return new TokenValidationResult { IsValid = false }; + return new TokenValidationResponse { IsValid = false }; } } } -- cgit v1.2.3