[FrontendWebApi] myBaseApi 註解消除
This commit is contained in:
parent
c49bb86d81
commit
d7c28fa573
@ -40,45 +40,45 @@ namespace FrontendWebApi.ApiControllers
|
||||
[Authorize]
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
//controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
|
||||
//actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
|
||||
controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
|
||||
actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
|
||||
|
||||
//var ctx = filterContext.HttpContext;
|
||||
//ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||
//ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
|
||||
//ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
|
||||
//EDFunction edFunction = new EDFunction();
|
||||
//myUser = new JwtGet()
|
||||
//{
|
||||
// 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(),
|
||||
// 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(),
|
||||
// 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(),
|
||||
//};
|
||||
var ctx = filterContext.HttpContext;
|
||||
ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||
ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
|
||||
ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
|
||||
EDFunction edFunction = new EDFunction();
|
||||
myUser = new JwtGet()
|
||||
{
|
||||
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(),
|
||||
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(),
|
||||
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(),
|
||||
};
|
||||
|
||||
//if (myUser.exp == 0)
|
||||
//{
|
||||
// jwt_str = "Jwt Token不合法";
|
||||
// jwtlife = false;
|
||||
// filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
|
||||
// {
|
||||
// jwtlife = true;
|
||||
// JwtLogin jwtLoing = new JwtLogin()
|
||||
// {
|
||||
// account = myUser.account,
|
||||
// email = myUser.email,
|
||||
// full_name = myUser.full_name,
|
||||
// userinfo_guid = myUser.userinfo_guid
|
||||
// };
|
||||
// jwt_str = jwt.GenerateToken(jwtLoing).token;
|
||||
// }
|
||||
//}
|
||||
if (myUser.exp == 0)
|
||||
{
|
||||
jwt_str = "Jwt Token不合法";
|
||||
jwtlife = false;
|
||||
filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
|
||||
{
|
||||
jwtlife = true;
|
||||
JwtLogin jwtLoing = new JwtLogin()
|
||||
{
|
||||
account = myUser.account,
|
||||
email = myUser.email,
|
||||
full_name = myUser.full_name,
|
||||
userinfo_guid = myUser.userinfo_guid
|
||||
};
|
||||
jwt_str = jwt.GenerateToken(jwtLoing).token;
|
||||
}
|
||||
}
|
||||
base.OnActionExecuting(filterContext);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user