Exemple #1
0
        public ActionResult Logout(string lang)
        {
            _accountService.Logout();

            TempData["Message"] = "Logout.Submit.Success";

            return(Redirect(AccountRedirectUrls.Home(lang)));
        }
Exemple #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.IsChildAction)
            {
                return;
            }

            var action   = filterContext.ActionDescriptor;
            var context  = filterContext.HttpContext;
            var language = GetLanguage(context.Request);

            var loginUrl = AccountRedirectUrls.LoginPage(language);
            var homeUrl  = AccountRedirectUrls.Home(language);

            if (HasAttribute <AuthorizedOnlyAttribute>(action) && !IsAuthenticated(context))
            {
                filterContext.Result = new RedirectResult(loginUrl);
            }

            if (HasAttribute <GuestsOnlyAttribute>(action) && IsAuthenticated(context))
            {
                filterContext.Result = new RedirectResult(homeUrl);
            }
        }