[前台] 修改前台api jwttoken

This commit is contained in:
dev02 2023-05-10 15:34:15 +08:00
parent 279950b63e
commit 398acd2a74

View File

@ -48,49 +48,49 @@ namespace FrontendWebApi.ApiControllers
ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*"); ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
EDFunction edFunction = new EDFunction(); EDFunction edFunction = new EDFunction();
//myUser = new JwtGet() myUser = new JwtGet()
//{ {
// account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(), account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(),
// email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(), email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(),
// full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(), full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(),
// exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
// nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
// userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(), userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(),
//}; };
//if (myUser.exp == 0) if (myUser.exp == 0)
//{ {
// jwt_str = "Jwt Token不合法"; jwt_str = "Jwt Token不合法";
// jwtlife = false; jwtlife = false;
// filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized }); filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
//} }
//else else
//{ {
// if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
// { {
// jwtlife = true; jwtlife = true;
// JwtLogin jwtLoing = new JwtLogin() JwtLogin jwtLoing = new JwtLogin()
// { {
// account = myUser.account, account = myUser.account,
// email = myUser.email, email = myUser.email,
// full_name = myUser.full_name, full_name = myUser.full_name,
// userinfo_guid = myUser.userinfo_guid userinfo_guid = myUser.userinfo_guid
// }; };
// jwt_str = jwt.GenerateToken(jwtLoing).token; jwt_str = jwt.GenerateToken(jwtLoing).token;
// } }
//} }
//if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
//{ {
// jwtlife = true; jwtlife = true;
// JwtLogin jwtLoing = new JwtLogin() JwtLogin jwtLoing = new JwtLogin()
// { {
// account ="webUser", account = "webUser",
// email = "webUser@gmail.com", email = "webUser@gmail.com",
// full_name = "webUser", full_name = "webUser",
// userinfo_guid = "6ac24708-3a40-4199-88c5-22df310cd1a8" userinfo_guid = "6ac24708-3a40-4199-88c5-22df310cd1a8"
// }; };
// jwt_str = jwt.GenerateToken(jwtLoing).token; jwt_str = jwt.GenerateToken(jwtLoing).token;
//} }
base.OnActionExecuting(filterContext); base.OnActionExecuting(filterContext);
} }
} }