コード例 #1
0
        public ActionResult ActivateAccount(string lang, string token)
        {
            var loginPageUrl = AccountRedirectUrls.LoginPage(lang);
            var result       = _accountService.ActivateAccount(token);

            if (result)
            {
                CookiesExtensions.CreateCookie(CookieVariables.TempMessageCookie, "ActivateAccount.Submit.Success");
            }

            return(Redirect(loginPageUrl));
        }
コード例 #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);
            }
        }