[FrontendWebApi] myBaseApi 註解消除
This commit is contained in:
parent
c49bb86d81
commit
d7c28fa573
@ -40,45 +40,45 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||||
{
|
{
|
||||||
//controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
|
controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
|
||||||
//actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
|
actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
|
||||||
|
|
||||||
//var ctx = filterContext.HttpContext;
|
var ctx = filterContext.HttpContext;
|
||||||
//ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||||
//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;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
base.OnActionExecuting(filterContext);
|
base.OnActionExecuting(filterContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user