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); }
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); }
public Negotiator Logout() { return(View["LogoutPage"].WithCookie(FormsAuthentication.CreateLogoutCookie())); }