summaryrefslogtreecommitdiffstats
path: root/samples/OAuthAuthorizationServer/Controllers/AccountController.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-08-11 19:29:31 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-08-11 19:29:31 -0700
commit93199748de57054f40085e95db5d586e9728abb7 (patch)
tree28aba78cdf92917d8caa2f4a56235061c9bd67ec /samples/OAuthAuthorizationServer/Controllers/AccountController.cs
parent56ccd9ee97eababf7b9f9f053a8c18dd46007a6f (diff)
downloadDotNetOpenAuth-93199748de57054f40085e95db5d586e9728abb7.zip
DotNetOpenAuth-93199748de57054f40085e95db5d586e9728abb7.tar.gz
DotNetOpenAuth-93199748de57054f40085e95db5d586e9728abb7.tar.bz2
Removed database component from the Resource Server sample.
Diffstat (limited to 'samples/OAuthAuthorizationServer/Controllers/AccountController.cs')
-rw-r--r--samples/OAuthAuthorizationServer/Controllers/AccountController.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/samples/OAuthAuthorizationServer/Controllers/AccountController.cs b/samples/OAuthAuthorizationServer/Controllers/AccountController.cs
index 963c7f4..d69a3b5 100644
--- a/samples/OAuthAuthorizationServer/Controllers/AccountController.cs
+++ b/samples/OAuthAuthorizationServer/Controllers/AccountController.cs
@@ -1,5 +1,6 @@
namespace OAuthAuthorizationServer.Controllers {
using System;
+ using System.Linq;
using System.Web.Mvc;
using System.Web.Security;
@@ -7,6 +8,7 @@
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
+ using OAuthAuthorizationServer.Code;
using OAuthAuthorizationServer.Models;
[HandleError]
@@ -44,6 +46,15 @@
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.
+ if (MvcApplication.DataContext.Users.FirstOrDefault(u => u.OpenIDClaimedIdentifier == identifier) == null) {
+ MvcApplication.DataContext.Users.InsertOnSubmit(new User {
+ OpenIDFriendlyIdentifier = response.FriendlyIdentifierForDisplay,
+ OpenIDClaimedIdentifier = response.ClaimedIdentifier,
+ });
+ }
+
FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false);
return this.Redirect(returnUrl ?? Url.Action("Index", "Home"));
default: