diff options
author | Richard Collette <rcollette@yahoo.com> | 2014-12-26 13:18:59 -0500 |
---|---|---|
committer | Richard Collette <rcollette@yahoo.com> | 2014-12-26 13:18:59 -0500 |
commit | b6bf259bc1d6a924207f5ac7e7b9b016aa87b73a (patch) | |
tree | ad429c35b75904caef2ea93951b512d0014e6a4c /samples/OAuthAuthorizationServer/Controllers/AccountController.cs | |
parent | 761bdd66da6e9ff6412a76b4a36cb721869f48b1 (diff) | |
download | DotNetOpenAuth-b6bf259bc1d6a924207f5ac7e7b9b016aa87b73a.zip DotNetOpenAuth-b6bf259bc1d6a924207f5ac7e7b9b016aa87b73a.tar.gz DotNetOpenAuth-b6bf259bc1d6a924207f5ac7e7b9b016aa87b73a.tar.bz2 |
Corrected indentation back to being tab based.
Diffstat (limited to 'samples/OAuthAuthorizationServer/Controllers/AccountController.cs')
-rw-r--r-- | samples/OAuthAuthorizationServer/Controllers/AccountController.cs | 101 |
1 files changed, 50 insertions, 51 deletions
diff --git a/samples/OAuthAuthorizationServer/Controllers/AccountController.cs b/samples/OAuthAuthorizationServer/Controllers/AccountController.cs index f3aa873..b3d24a2 100644 --- a/samples/OAuthAuthorizationServer/Controllers/AccountController.cs +++ b/samples/OAuthAuthorizationServer/Controllers/AccountController.cs @@ -4,77 +4,76 @@ using System.Threading.Tasks; using System.Web.Mvc; using System.Web.Security; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OpenId; - using DotNetOpenAuth.OpenId.RelyingParty; - using OAuthAuthorizationServer.Code; - using OAuthAuthorizationServer.Models; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.RelyingParty; + using OAuthAuthorizationServer.Code; + using OAuthAuthorizationServer.Models; - [HandleError] + [HandleError] public class AccountController : Controller { - // ************************************** - // URL: /Account/LogOn - // ************************************** + // ************************************** + // URL: /Account/LogOn + // ************************************** public ActionResult LogOn() { - return View(); - } + return View(); + } - [HttpPost] + [HttpPost] public async Task<ActionResult> LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { - var rp = new OpenIdRelyingParty(); - var request = await rp.CreateRequestAsync(model.UserSuppliedIdentifier, Realm.AutoDetect, new Uri(Request.Url, Url.Action("Authenticate"))); + var rp = new OpenIdRelyingParty(); + var request = await rp.CreateRequestAsync(model.UserSuppliedIdentifier, Realm.AutoDetect, new Uri(Request.Url, Url.Action("Authenticate"))); if (request != null) { if (returnUrl != null) { - request.AddCallbackArguments("returnUrl", returnUrl); - } + request.AddCallbackArguments("returnUrl", returnUrl); + } - var response = await request.GetRedirectingResponseAsync(); - Response.ContentType = response.Content.Headers.ContentType.ToString(); - return response.AsActionResult(); + var response = await request.GetRedirectingResponseAsync(); + Response.ContentType = response.Content.Headers.ContentType.ToString(); + return response.AsActionResult(); } else { - ModelState.AddModelError(string.Empty, "The identifier you supplied is not recognized as a valid OpenID Identifier."); - } - } + ModelState.AddModelError(string.Empty, "The identifier you supplied is not recognized as a valid OpenID Identifier."); + } + } - // If we got this far, something failed, redisplay form - return View(model); - } + // If we got this far, something failed, redisplay form + return View(model); + } public async Task<ActionResult> Authenticate(string returnUrl) { - var rp = new OpenIdRelyingParty(); - var response = await rp.GetResponseAsync(Request); + var rp = new OpenIdRelyingParty(); + var response = await rp.GetResponseAsync(Request); if (response != null) { switch (response.Status) { - case AuthenticationStatus.Authenticated: - // Make sure we have a user account for this guy. - string identifier = response.ClaimedIdentifier; // convert to string so LinqToSQL expression parsing works. + case AuthenticationStatus.Authenticated: + // Make sure we have a user account for this guy. + string identifier = response.ClaimedIdentifier; // convert to string so LinqToSQL expression parsing works. if (MvcApplication.DataContext.Users.FirstOrDefault(u => u.OpenIDClaimedIdentifier == identifier) == null) { MvcApplication.DataContext.Users.InsertOnSubmit(new User { - OpenIDFriendlyIdentifier = response.FriendlyIdentifierForDisplay, - OpenIDClaimedIdentifier = response.ClaimedIdentifier, - }); - } + OpenIDFriendlyIdentifier = response.FriendlyIdentifierForDisplay, + OpenIDClaimedIdentifier = response.ClaimedIdentifier, + }); + } - FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false); - return this.Redirect(returnUrl ?? Url.Action("Index", "Home")); + FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false); + return this.Redirect(returnUrl ?? Url.Action("Index", "Home")); + default: + ModelState.AddModelError(string.Empty, "An error occurred during login."); + break; + } + } - default: - ModelState.AddModelError(string.Empty, "An error occurred during login."); - break; - } - } + return this.View("LogOn"); + } - return this.View("LogOn"); - } - - // ************************************** - // URL: /Account/LogOff - // ************************************** + // ************************************** + // URL: /Account/LogOff + // ************************************** public ActionResult LogOff() { - FormsAuthentication.SignOut(); + FormsAuthentication.SignOut(); - return RedirectToAction("Index", "Home"); - } - } + return RedirectToAction("Index", "Home"); + } + } }
\ No newline at end of file |