Example #1
0
        private Response SetContextUserFromAuthenticationCookie(NancyContext ctx)
        {
            var username = FormsAuthentication.GetAuthUsernameFromCookie(ctx);

            if (username.IsNullOrWhitespace())
            {
                return(ctx.GetRedirect("/mz-login?returnUrl=" + Request.Url.Path).AddCookie(FormsAuthentication.CreateLogoutCookie()));
            }

            ctx.CurrentUser = new BlogUserIdentity(username, new string[] { "admin" });

            return(null);
        }
Example #2
0
        private Response SetContextUserFromAuthenticationCookie(NancyContext ctx)
        {
            var username = FormsAuthentication.GetAuthUsernameFromCookie(ctx);

            if (username.IsNullOrWhitespace())
            {
                return(ctx.GetRedirect("/session/login?returnUrl=" + Request.Url.Path));
            }

            ctx.CurrentUser = new UserIdentityWrapper(username, new string[] {});

            return(null);
        }