Skip to content
Browse files

FormsAuthenticationConfiguration.EnableUnauthorizedLoginRedirect

  • Loading branch information...
1 parent 63b7a9c commit 153d11685baf9a1bd0a334027ebc1dce4119360b @prabirshrestha prabirshrestha committed with thecodejunkie Aug 7, 2012
View
5 src/Nancy.Authentication.Forms/FormsAuthentication.cs
@@ -58,7 +58,10 @@ public static void Enable(IPipelines pipelines, FormsAuthenticationConfiguration
currentConfiguration = configuration;
pipelines.BeforeRequest.AddItemToStartOfPipeline(GetLoadAuthenticationHook(configuration));
- pipelines.AfterRequest.AddItemToEndOfPipeline(GetRedirectToLoginHook(configuration));
+ if (configuration.EnableUnauthorizedLoginRedirect)
+ {
+ pipelines.AfterRequest.AddItemToEndOfPipeline(GetRedirectToLoginHook(configuration));
+ }
}
/// <summary>
View
8 src/Nancy.Authentication.Forms/FormsAuthenticationConfiguration.cs
@@ -24,6 +24,7 @@ public FormsAuthenticationConfiguration(CryptographyConfiguration cryptographyCo
{
CryptographyConfiguration = cryptographyConfiguration;
RedirectQuerystringKey = DefaultRedirectQuerystringKey;
+ EnableUnauthorizedLoginRedirect = true;
}
/// <summary>
@@ -48,6 +49,11 @@ public FormsAuthenticationConfiguration(CryptographyConfiguration cryptographyCo
public bool RequiresSSL { get; set; }
/// <summary>
+ /// Gets or sets whether to redirect to login page during unauthorized access.
+ /// </summary>
+ public bool EnableUnauthorizedLoginRedirect { get; set; }
+
+ /// <summary>
/// Gets or sets the cryptography configuration
/// </summary>
public CryptographyConfiguration CryptographyConfiguration { get; set; }
@@ -88,4 +94,4 @@ public virtual bool IsValid
}
}
}
-}
+}

0 comments on commit 153d116

Please sign in to comment.
Something went wrong with that request. Please try again.