|
@@ -1,11 +1,13 @@
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
+using NetTaste;
|
|
using OASystem.API.OAMethodLib.JuHeAPI;
|
|
using OASystem.API.OAMethodLib.JuHeAPI;
|
|
using OASystem.Domain.Dtos.Business;
|
|
using OASystem.Domain.Dtos.Business;
|
|
using SqlSugar.Extensions;
|
|
using SqlSugar.Extensions;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.Security.Claims;
|
|
using System.Security.Claims;
|
|
|
|
+using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
|
|
namespace OASystem.API.OAMethodLib
|
|
namespace OASystem.API.OAMethodLib
|
|
{
|
|
{
|
|
@@ -37,7 +39,9 @@ namespace OASystem.API.OAMethodLib
|
|
*/
|
|
*/
|
|
|
|
|
|
new Claim(JwtRegisteredClaimNames.Jti, tokenModel.UserId.ToString()),
|
|
new Claim(JwtRegisteredClaimNames.Jti, tokenModel.UserId.ToString()),
|
|
- new Claim(JwtRegisteredClaimNames.GivenName, tokenModel.UserName),
|
|
|
|
|
|
+ //new Claim(JwtRegisteredClaimNames.GivenName, tokenModel.UserName),
|
|
|
|
+ new Claim("UserName", tokenModel.UserName),
|
|
|
|
+ //new Claim("UserId", tokenModel.UserId.ToString()),
|
|
new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"),
|
|
new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"),
|
|
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
|
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
|
//这个就是过期时间,目前是过期7200秒,可自定义,注意JWT有自己的缓冲过期时间
|
|
//这个就是过期时间,目前是过期7200秒,可自定义,注意JWT有自己的缓冲过期时间
|
|
@@ -88,13 +92,14 @@ namespace OASystem.API.OAMethodLib
|
|
try
|
|
try
|
|
{
|
|
{
|
|
jwtToken.Payload.TryGetValue(ClaimTypes.Role, out role);
|
|
jwtToken.Payload.TryGetValue(ClaimTypes.Role, out role);
|
|
- jwtToken.Payload.TryGetValue(ClaimTypes.GivenName, out userName);
|
|
|
|
|
|
+ jwtToken.Payload.TryGetValue("UserName", out userName);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
Console.WriteLine(e);
|
|
Console.WriteLine(e);
|
|
throw;
|
|
throw;
|
|
}
|
|
}
|
|
|
|
+
|
|
var tm = new TokenModelJwt
|
|
var tm = new TokenModelJwt
|
|
{
|
|
{
|
|
UserId = (jwtToken.Id).ObjToInt(),
|
|
UserId = (jwtToken.Id).ObjToInt(),
|