summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
diff options
context:
space:
mode:
authorMicrosoft <aspnet@microsoft.com>2012-05-14 13:36:35 -0700
committerMicrosoft <aspnet@microsoft.com>2012-05-14 13:36:35 -0700
commit27d1a1a7164d757af4df9f050a577bf7f40a89bb (patch)
tree72d74de65283ba4c3ae4f09c0f3bde3a3c614039 /src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
parent444d2c18148324cda8a968891bf9704281e01060 (diff)
downloadDotNetOpenAuth-27d1a1a7164d757af4df9f050a577bf7f40a89bb.zip
DotNetOpenAuth-27d1a1a7164d757af4df9f050a577bf7f40a89bb.tar.gz
DotNetOpenAuth-27d1a1a7164d757af4df9f050a577bf7f40a89bb.tar.bz2
Make change so that the VerifyAuthentication overload with no returnUrl parameter will use the current request as the return url.
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs')
-rw-r--r--src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs47
1 files changed, 18 insertions, 29 deletions
diff --git a/src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs b/src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
index 32e6b04..6ddad04 100644
--- a/src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
+++ b/src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
@@ -156,7 +156,7 @@ namespace DotNetOpenAuth.AspNet {
/// </summary>
/// <returns>The result of the authentication.</returns>
public AuthenticationResult VerifyAuthentication() {
- return this.VerifyAuthenticationCore(() => this.authenticationProvider.VerifyAuthentication(this.requestContext));
+ return VerifyAuthentication(returnUrl: null);
}
/// <summary>
@@ -170,8 +170,6 @@ namespace DotNetOpenAuth.AspNet {
/// The result of the authentication.
/// </returns>
public AuthenticationResult VerifyAuthentication(string returnUrl) {
- Requires.NotNullOrEmpty(returnUrl, "returnUrl");
-
// Only OAuth2 requires the return url value for the verify authenticaiton step
OAuth2Client oauth2Client = this.authenticationProvider as OAuth2Client;
if (oauth2Client != null) {
@@ -188,38 +186,29 @@ namespace DotNetOpenAuth.AspNet {
// the login when user is redirected back to this page
uri = uri.AttachQueryStringParameter(ProviderQueryStringName, this.authenticationProvider.ProviderName);
- return this.VerifyAuthenticationCore(() => oauth2Client.VerifyAuthentication(this.requestContext, uri));
+ try {
+ AuthenticationResult result = oauth2Client.VerifyAuthentication(this.requestContext, uri);
+ if (!result.IsSuccessful) {
+ // if the result is a Failed result, creates a new Failed response which has providerName info.
+ result = new AuthenticationResult(
+ isSuccessful: false,
+ provider: this.authenticationProvider.ProviderName,
+ providerUserId: null,
+ userName: null,
+ extraData: null);
+ }
+
+ return result;
+ }
+ catch (HttpException exception) {
+ return new AuthenticationResult(exception.GetBaseException(), this.authenticationProvider.ProviderName);
+ }
}
else {
return this.VerifyAuthentication();
}
}
- /// <summary>
- /// Helper to verify authentiation.
- /// </summary>
- /// <param name="verifyAuthenticationCall">The real authentication action.</param>
- /// <returns>Authentication result</returns>
- private AuthenticationResult VerifyAuthenticationCore(Func<AuthenticationResult> verifyAuthenticationCall) {
- try {
- AuthenticationResult result = verifyAuthenticationCall();
- if (!result.IsSuccessful) {
- // if the result is a Failed result, creates a new Failed response which has providerName info.
- result = new AuthenticationResult(
- isSuccessful: false,
- provider: this.authenticationProvider.ProviderName,
- providerUserId: null,
- userName: null,
- extraData: null);
- }
-
- return result;
- }
- catch (HttpException exception) {
- return new AuthenticationResult(exception.GetBaseException(), this.authenticationProvider.ProviderName);
- }
- }
-
#endregion
}
} \ No newline at end of file