public void OnAuthentication(AuthenticationContext filterContext)
 {
     if (!CustomPrincipal.SessionAuthentication())
     {
         filterContext.Result = new HttpUnauthorizedResult();
     }
 }
Exemple #2
0
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     if (CustomPrincipal.SessionAuthentication() == false)
     {
         if (filterContext.HttpContext.Request.IsAjaxRequest())
         {
             UrlHelper urlHelper = new UrlHelper(filterContext.RequestContext);
             filterContext.Result = new JsonResult
             {
                 Data = new BaseResponse()
                 {
                     IsSucceed = false,
                     Message   = "Oturumunuz sonlanmıştır. Lütfen tekrar giriş yapınız.",
                 },
                 JsonRequestBehavior = JsonRequestBehavior.AllowGet
             };
         }
         else
         {
             filterContext.Result = new RedirectToRouteResult("Default", new RouteValueDictionary(new
             {
                 action     = "UserIndex", //"Login",
                 controller = "Home",      //"Account",
                 ReturnUrl  = filterContext.HttpContext.Request.Url.AbsolutePath + filterContext.HttpContext.Request.Url.Query,
             }));
         }
     }
 }
Exemple #3
0
 // GET: Account
 public ActionResult Login()
 {
     if (CustomPrincipal.SessionAuthentication())
     {
         return(RedirectToHomePage());
     }
     return(View());
 }
        public ActionResult BaseInformation()
        {
            UserResponse response = new UserResponse();

            if (CustomPrincipal.SessionAuthentication())
            {
                response.UserView          = new UserView();
                response.UserView.Email    = base.UserEmail;
                response.UserView.Name     = base.UserName;
                response.UserView.Surname  = base.UserSurname;
                response.UserView.RoleName = base.RoleName;
            }

            return(PartialView("~/Views/Shared/_BaseInformation.cshtml", response));
        }
Exemple #5
0
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     if ((CustomPrincipal.SessionAuthentication()))
     {
         if (!(CustomPrincipal.SessionRole() == Role.Senior.ToString()))
         {
             var httpContext = filterContext.HttpContext;
             var request     = httpContext.Request;
             if (request.IsAjaxRequest())
             {
                 filterContext.Result = new JsonResult
                 {
                     Data = new BaseResponse()
                     {
                         IsSucceed  = false,
                         Message    = "İşlem yetkiniz bulunmamaktadır.",
                         StatusCode = 503
                     },
                     JsonRequestBehavior = JsonRequestBehavior.AllowGet
                 };
             }
             else
             {
                 filterContext.Result = new RedirectToRouteResult("Default",
                                                                  new RouteValueDictionary
                 {
                     { "action", "NotAuthorization" },
                     { "controller", "Error" }
                 });
             }
         }
     }
     else
     {
         base.OnAuthorization(filterContext);
     }
 }
Exemple #6
0
 protected override void OnAuthorization(AuthorizationContext filterContext)
 {
     CustomPrincipal.SessionAuthentication();
     base.OnAuthorization(filterContext);
 }