# HG changeset patch # User Adam Chlipala # Date 1311517430 14400 # Node ID 328a429dfedb543e5fe4c6143f0b9c1a5431b5d4 # Parent ba203b170476f37b270b681b98e57f90ad6ce9db renew diff -r ba203b170476 -r 328a429dfedb src/ur/openidUser.ur --- a/src/ur/openidUser.ur Tue Jul 19 09:27:10 2011 -0400 +++ b/src/ur/openidUser.ur Sun Jul 24 10:23:50 2011 -0400 @@ -90,7 +90,7 @@ else currentUrl - val current = + fun current' tweakSession = login <- getCookie auth; case login of Some (LoggedIn login) => @@ -107,11 +107,20 @@ WHERE identity.User = {[login.User]} AND identity.Identifier = {[ident]}); if valid then + tweakSession login.Session; return (Some login.User) else error Session not authorized to act as user) | _ => return None + val current = current' (fn _ => return ()) + + val renew = current' (fn id => + now <- now; + dml (UPDATE session + SET Expires = {[addSeconds now M.sessionLifetime]} + WHERE Id = {[id]})) + fun validUser s = String.length s > 0 && String.length s < 20 && String.all Char.isAlnum s diff -r ba203b170476 -r 328a429dfedb src/ur/openidUser.urs --- a/src/ur/openidUser.urs Tue Jul 19 09:27:10 2011 -0400 +++ b/src/ur/openidUser.urs Sun Jul 24 10:23:50 2011 -0400 @@ -105,6 +105,10 @@ val current : transaction (option user) (* Figure out which, if any, user is logged in on this connection. *) + val renew : transaction (option user) + (* Like [current], but also resets the expiration time of the user's + * session, if one is found. *) + val main : (string -> xbody -> transaction page) -> transaction {Status : xbody, Other : {Url : url, Xml : xbody}}