# HG changeset patch # User Adam Chlipala # Date 1295202094 18000 # Node ID e5df3d3554d3cf457979a6694bda0da28093560d # Parent 70ab0230649bcc59436173e6ff5147371e87f5fb fakeId parameter diff -r 70ab0230649b -r e5df3d3554d3 src/ur/openidUser.ur --- a/src/ur/openidUser.ur Sat Jan 15 15:24:42 2011 -0500 +++ b/src/ur/openidUser.ur Sun Jan 16 13:21:34 2011 -0500 @@ -18,6 +18,7 @@ val association : Openid.association_mode val realm : option string val formClass : css_class + val fakeId : option string end) = struct type user = string @@ -175,6 +176,35 @@ redirect (bless after) | None => error Missing session cookie + fun fakeCallback ident after ses = + av <- getCookie auth; + case av of + Some (SigningUp signup) => + invalid <- oneRowE1 (SELECT COUNT( * ) = 0 + FROM session + WHERE session.Id = {[signup.Session]} + AND session.Key = {[signup.Key]}); + if invalid then + error Invalid or expired session + else + dml (UPDATE session + SET Identifier = {[Some ident]} + WHERE Id = {[signup.Session]}); + signupDetails after + | Some (LoggedIn login) => + invalid <- oneRowE1 (SELECT COUNT( * ) = 0 + FROM session + WHERE session.Id = {[login.Session]} + AND session.Key = {[login.Key]}); + if invalid then + error Invalid or expired session + else + dml (UPDATE session + SET Identifier = {[Some ident]} + WHERE Id = {[login.Session]}); + redirect (bless after) + | None => error Missing session cookie + fun newSession () = ses <- nextval sessionIds; now <- now; @@ -196,11 +226,14 @@ Expires = None, Secure = M.secureCookies}; ses <- return ses.Session; - msg <- Openid.authenticate (opCallback after ses) - {Association = M.association, - Realm = M.realm, - Identifier = ident}; - error Login with your identity provider failed: {[msg]} + if M.fakeId = Some ident then + fakeCallback ident after ses + else + msg <- Openid.authenticate (opCallback after ses) + {Association = M.association, + Realm = M.realm, + Identifier = ident}; + error Login with your identity provider failed: {[msg]} fun doSignup after r = ses <- newSession (); @@ -208,11 +241,14 @@ Expires = None, Secure = M.secureCookies}; ses <- return ses.Session; - msg <- Openid.authenticate (opCallback after ses) - {Association = M.association, - Realm = M.realm, - Identifier = r.Identifier}; - error Login with your identity provider failed: {[msg]} + if M.fakeId = Some r.Identifier then + fakeCallback r.Identifier after ses + else + msg <- Openid.authenticate (opCallback after ses) + {Association = M.association, + Realm = M.realm, + Identifier = r.Identifier}; + error Login with your identity provider failed: {[msg]} fun signup after = wrap "Account Signup" diff -r 70ab0230649b -r e5df3d3554d3 src/ur/openidUser.urs --- a/src/ur/openidUser.urs Sat Jan 15 15:24:42 2011 -0500 +++ b/src/ur/openidUser.urs Sun Jan 16 13:21:34 2011 -0500 @@ -59,6 +59,11 @@ val formClass : css_class (* CSS class for ,
, and elements used in * sign-up form *) + + val fakeId : option string + (* If set, this string is always accepted as a verified + * identifier, which can be useful during development (say, + * when you're off-network). *) end) : sig type user diff -r 70ab0230649b -r e5df3d3554d3 tests/utest.ur --- a/tests/utest.ur Sat Jan 15 15:24:42 2011 -0500 +++ b/tests/utest.ur Sun Jan 16 13:21:34 2011 -0500 @@ -27,6 +27,8 @@ fun choose _ r = return r val formClass = inputs + + val fakeId = None end) fun wrap title body =