diff options
author | David Christiansen <coding@davedoes.net> | 2012-03-15 22:10:55 +0000 |
---|---|---|
committer | David Christiansen <coding@davedoes.net> | 2012-03-15 22:10:55 +0000 |
commit | a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f (patch) | |
tree | a3057157fa3287e0c0c4cc49be1854f9aa63d321 /src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs | |
parent | 02ce959db12fec57e846e5ebfa662cd0327ce69c (diff) | |
download | DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.zip DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.gz DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.bz2 |
W.I.P.
* Initial migration and reference to DNOA Nuget packages (From teamcity.dotnetopenauth.net)
* Awaiting fix to DotNetOpenAuth.OpenIdOAuth.nuspec in order to complete migration.
Diffstat (limited to 'src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs')
-rw-r--r-- | src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs b/src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs new file mode 100644 index 0000000..5e0c21f --- /dev/null +++ b/src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs @@ -0,0 +1,48 @@ +namespace OpenIdProviderMvc.Controllers { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.Mvc; + using System.Web.Mvc.Ajax; + + public class UserController : Controller { + /// <summary> + /// Identities the specified id. + /// </summary> + /// <param name="id">The username or anonymous identifier.</param> + /// <param name="anon">if set to <c>true</c> then <paramref name="id"/> represents an anonymous identifier rather than a username.</param> + /// <returns>The view to display.</returns> + public ActionResult Identity(string id, bool anon) { + if (!anon) { + var redirect = this.RedirectIfNotNormalizedRequestUri(id); + if (redirect != null) { + return redirect; + } + } + + if (Request.AcceptTypes != null && Request.AcceptTypes.Contains("application/xrds+xml")) { + return View("Xrds"); + } + + if (!anon) { + this.ViewData["username"] = id; + } + + return View(); + } + + public ActionResult Xrds(string id) { + return View(); + } + + private ActionResult RedirectIfNotNormalizedRequestUri(string user) { + Uri normalized = Models.User.GetClaimedIdentifierForUser(user); + if (Request.Url != normalized) { + return Redirect(normalized.AbsoluteUri); + } + + return null; + } + } +} |