/// <summary> /// Logs the user out and redirects them to a URL /// </summary> /// <param name="context">Current context</param> /// <param name="redirectUrl">URL to redirect to</param> /// <returns>Nancy response</returns> public static Response LogOutAndRedirectResponse(NancyContext context, string redirectUrl) { var response = new RedirectResponse(redirectUrl); var authenticationCookie = BuildLogoutCookie(currentConfiguration); response.AddCookie(authenticationCookie); return(response); }
/// <summary> /// Creates a response that sets the authentication cookie and redirects /// the user back to where they came from. /// </summary> /// <param name="context">Current context</param> /// <param name="userIdentifier">User identifier guid</param> /// <param name="cookieExpiry">Optional expiry date for the cookie (for 'Remember me')</param> /// <param name="fallbackRedirectUrl">Url to redirect to if none in the querystring</param> /// <returns>Nancy response</returns> public static Response UserLoggedInRedirectResponse(NancyContext context, Guid userIdentifier, DateTime?cookieExpiry = null, string fallbackRedirectUrl = "/") { var redirectUrl = fallbackRedirectUrl; if (context.Request.Query[REDIRECT_QUERYSTRING_KEY].HasValue) { redirectUrl = context.Request.Query[REDIRECT_QUERYSTRING_KEY]; } var response = new RedirectResponse(redirectUrl); var authenticationCookie = BuildCookie(userIdentifier, cookieExpiry, currentConfiguration); response.AddCookie(authenticationCookie); return(response); }
/// <summary> /// Logs the user out and redirects them to a URL /// </summary> /// <param name="context">Current context</param> /// <param name="redirectUrl">URL to redirect to</param> /// <returns>Nancy response</returns> public static Response LogOutAndRedirectResponse(NancyContext context, string redirectUrl) { var response = new RedirectResponse(redirectUrl); var authenticationCookie = BuildLogoutCookie(currentConfiguration); response.AddCookie(authenticationCookie); return response; }
/// <summary> /// Creates a response that sets the authentication cookie and redirects /// the user back to where they came from. /// </summary> /// <param name="context">Current context</param> /// <param name="userIdentifier">User identifier guid</param> /// <param name="cookieExpiry">Optional expiry date for the cookie (for 'Remember me')</param> /// <param name="fallbackRedirectUrl">Url to redirect to if none in the querystring</param> /// <returns>Nancy response</returns> public static Response UserLoggedInRedirectResponse(NancyContext context, Guid userIdentifier, DateTime? cookieExpiry = null, string fallbackRedirectUrl = "/") { var redirectUrl = fallbackRedirectUrl; if (context.Request.Query[REDIRECT_QUERYSTRING_KEY].HasValue) { redirectUrl = context.Request.Query[REDIRECT_QUERYSTRING_KEY]; } var response = new RedirectResponse(redirectUrl); var authenticationCookie = BuildCookie(userIdentifier, cookieExpiry, currentConfiguration); response.AddCookie(authenticationCookie); return response; }