aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/JwtService.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-04-11 21:13:15 +0800
committerGitHub <noreply@github.com>2019-04-11 21:13:15 +0800
commit8c5e7069d2651fb6fae641dfe482d7a0910b3fd1 (patch)
tree49dc35791778a4ed1403319708046ac8823210b6 /Timeline/Services/JwtService.cs
parent1eb6d9abfc24eec380b7b5d7423102a53041239e (diff)
parentf562660f52ce055e243b937a988f04c90ad3ae55 (diff)
downloadtimeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.tar.gz
timeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.tar.bz2
timeline-8c5e7069d2651fb6fae641dfe482d7a0910b3fd1.zip
Merge pull request #19 from crupest/18-createtoken
Change create token api.
Diffstat (limited to 'Timeline/Services/JwtService.cs')
-rw-r--r--Timeline/Services/JwtService.cs26
1 files changed, 10 insertions, 16 deletions
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
{
/// <summary>
@@ -30,17 +24,17 @@ namespace Timeline.Services
/// <summary>
/// Validate a JWT token.
/// Return null is <paramref name="token"/> is null.
- /// If token is invalid, return a <see cref="TokenValidationResult"/> with
- /// <see cref="TokenValidationResult.IsValid"/> set to false and
- /// <see cref="TokenValidationResult.UserInfo"/> set to null.
- /// If token is valid, return a <see cref="TokenValidationResult"/> with
- /// <see cref="TokenValidationResult.IsValid"/> set to true and
- /// <see cref="TokenValidationResult.UserInfo"/> filled with the user info
+ /// If token is invalid, return a <see cref="TokenValidationResponse"/> with
+ /// <see cref="TokenValidationResponse.IsValid"/> set to false and
+ /// <see cref="TokenValidationResponse.UserInfo"/> set to null.
+ /// If token is valid, return a <see cref="TokenValidationResponse"/> with
+ /// <see cref="TokenValidationResponse.IsValid"/> set to true and
+ /// <see cref="TokenValidationResponse.UserInfo"/> filled with the user info
/// in the token.
/// </summary>
/// <param name="token">The token string to validate.</param>
/// <returns>Null if <paramref name="token"/> is null. Or the result.</returns>
- 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 };
}
}
}