summaryrefslogtreecommitdiffstats
path: root/samples/RelyingPartyMvc/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'samples/RelyingPartyMvc/Controllers')
-rw-r--r--samples/RelyingPartyMvc/Controllers/HomeController.cs6
-rw-r--r--samples/RelyingPartyMvc/Controllers/UserController.cs30
2 files changed, 21 insertions, 15 deletions
diff --git a/samples/RelyingPartyMvc/Controllers/HomeController.cs b/samples/RelyingPartyMvc/Controllers/HomeController.cs
index 15ae689..65caae2 100644
--- a/samples/RelyingPartyMvc/Controllers/HomeController.cs
+++ b/samples/RelyingPartyMvc/Controllers/HomeController.cs
@@ -6,11 +6,11 @@ using System.Web.Mvc;
namespace RelyingPartyMvc.Controllers {
public class HomeController : Controller {
- public void Index() {
+ public ActionResult Index() {
Response.AppendHeader("X-XRDS-Location",
new Uri(Request.Url, Response.ApplyAppPathModifier("~/Home/xrds")).AbsoluteUri);
- RenderView("Index");
+ return View("Index");
}
- public void Xrds() { RenderView("Xrds"); }
+ public ActionResult Xrds() { return View("Xrds"); }
}
}
diff --git a/samples/RelyingPartyMvc/Controllers/UserController.cs b/samples/RelyingPartyMvc/Controllers/UserController.cs
index 991a4bd..35f6966 100644
--- a/samples/RelyingPartyMvc/Controllers/UserController.cs
+++ b/samples/RelyingPartyMvc/Controllers/UserController.cs
@@ -5,27 +5,34 @@ using System.Web;
using System.Web.Mvc;
using DotNetOpenId.RelyingParty;
using System.Web.Security;
+using DotNetOpenId;
namespace RelyingPartyMvc.Controllers {
public class UserController : Controller {
- public void Index() {
+ public ActionResult Index() {
if (!User.Identity.IsAuthenticated) Response.Redirect("/User/Login?ReturnUrl=Index");
- RenderView("Index");
+ return View("Index");
}
- public void Logout() {
+ public ActionResult Logout() {
FormsAuthentication.SignOut();
- Response.Redirect("/Home");
+ return Redirect("/Home");
}
- public void Login() {
+ public ActionResult Login() {
// Stage 1: display login form to user
- RenderView("Login");
+ return View("Login");
}
- public void Authenticate() {
+ public ActionResult Authenticate() {
var openid = new OpenIdRelyingParty();
if (openid.Response == null) {
// Stage 2: user submitting Identifier
- openid.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
+ Identifier id;
+ if (Identifier.TryParse(Request.Form["openid_identifier"], out id)) {
+ openid.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
+ } else {
+ ViewData["Message"] = "Invalid identifier";
+ return View("Login");
+ }
} else {
// Stage 3: OpenID Provider sending assertion response
switch (openid.Response.Status) {
@@ -34,14 +41,13 @@ namespace RelyingPartyMvc.Controllers {
break;
case AuthenticationStatus.Canceled:
ViewData["Message"] = "Canceled at provider";
- RenderView("Login");
- break;
+ return View("Login");
case AuthenticationStatus.Failed:
ViewData["Message"] = openid.Response.Exception.Message;
- RenderView("Login");
- break;
+ return View("Login");
}
}
+ return new EmptyResult();
}
}
}