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

            if (username.IsNullOrWhitespace())
            {
                var url    = string.Format("/mz-login?returnUrl={0}", Request.Url.Path);
                var cookie = FormsAuthentication.CreateLogoutCookie();
                return(ctx.GetRedirect(url).WithCookie(cookie));
            }

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

            return(null);
        }
예제 #2
0
        private Response SetCurrentUserToViewBag(NancyContext ctx)
        {
            var author = _viewProjectionFactory.Get <string, Author>(ctx.CurrentUser.UserName);

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

            ViewBag.CurrentUser = author;
            return(null);
        }
예제 #3
0
 public Negotiator Logout()
 {
     return(View["LogoutPage"].WithCookie(FormsAuthentication.CreateLogoutCookie()));
 }