summaryrefslogtreecommitdiffstats
path: root/projecttemplates/MvcRelyingParty/Controllers/AccountController.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-03-07 07:16:42 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-03-07 07:16:42 -0800
commit8ce3d28d5d50aff215d18bf789ca4f6d4a63df09 (patch)
treede5ad8b3e805ec21993f9f972eb9d6a67e1268e5 /projecttemplates/MvcRelyingParty/Controllers/AccountController.cs
parentea4463b29dc05d5ff715a80289bbe51d0e420c81 (diff)
downloadDotNetOpenAuth-8ce3d28d5d50aff215d18bf789ca4f6d4a63df09.zip
DotNetOpenAuth-8ce3d28d5d50aff215d18bf789ca4f6d4a63df09.tar.gz
DotNetOpenAuth-8ce3d28d5d50aff215d18bf789ca4f6d4a63df09.tar.bz2
AJAX login success messages are now processed.
Diffstat (limited to 'projecttemplates/MvcRelyingParty/Controllers/AccountController.cs')
-rw-r--r--projecttemplates/MvcRelyingParty/Controllers/AccountController.cs52
1 files changed, 15 insertions, 37 deletions
diff --git a/projecttemplates/MvcRelyingParty/Controllers/AccountController.cs b/projecttemplates/MvcRelyingParty/Controllers/AccountController.cs
index 52f8831..f6f4275 100644
--- a/projecttemplates/MvcRelyingParty/Controllers/AccountController.cs
+++ b/projecttemplates/MvcRelyingParty/Controllers/AccountController.cs
@@ -105,6 +105,20 @@
}
/// <summary>
+ /// Handles the positive assertion that comes from Providers to Javascript running in the browser.
+ /// </summary>
+ /// <returns>The action result.</returns>
+ /// <remarks>
+ /// This method instructs ASP.NET MVC to <i>not</i> validate input
+ /// because some OpenID positive assertions messages otherwise look like
+ /// hack attempts and result in errors when validation is turned on.
+ /// </remarks>
+ [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post), ValidateInput(false)]
+ public ActionResult LogOnReturnToAjax() {
+ return RelyingPartyUtilities.AjaxReturnTo(this.Request);
+ }
+
+ /// <summary>
/// Handles the positive assertion that comes from Providers.
/// </summary>
/// <returns>The action result.</returns>
@@ -157,43 +171,7 @@
throw new InvalidOperationException();
}
- // We prepare a JSON object with this interface:
- // class jsonResponse {
- // string claimedIdentifier;
- // Array requests; // never null
- // string error; // null if no error
- // }
- // Each element in the requests array looks like this:
- // class jsonAuthRequest {
- // string endpoint; // URL to the OP endpoint
- // string immediate; // URL to initiate an immediate request
- // string setup; // URL to initiate a setup request.
- // }
- IEnumerable<IAuthenticationRequest> requests = this.RelyingParty.CreateRequests(identifier, Realm.AutoDetect, Url.ActionFull("LogOnReturnTo")).CacheGeneratedResults();
- if (requests.Any()) {
- return new JsonResult {
- Data = new {
- claimedIdentifier = requests.First().ClaimedIdentifier,
- requests = requests.Select(req => new {
- endpoint = req.Provider.Uri.AbsoluteUri,
- immediate = GetRedirectUrl(req, true),
- setup = GetRedirectUrl(req, false),
- }).ToArray()
- },
- };
- } else {
- return new JsonResult {
- Data = new {
- requests = new object [0],
- error = "No OpenID endpoint found",
- }
- };
- }
- }
-
- private Uri GetRedirectUrl(IAuthenticationRequest request, bool immediate) {
- request.Mode = immediate ? AuthenticationRequestMode.Immediate : AuthenticationRequestMode.Setup;
- return request.RedirectingResponse.GetDirectUriRequest(this.RelyingParty.Channel);
+ return RelyingPartyUtilities.AjaxDiscover(identifier, Realm.AutoDetect, Url.ActionFull("LogOnReturnToAjax"));
}
[Authorize]