diff src/ur/openidUser.ur @ 50:328a429dfedb

renew
author Adam Chlipala <adam@chlipala.net>
date Sun, 24 Jul 2011 10:23:50 -0400
parents 72e942423f26
children a984dc1c8954
line wrap: on
line diff
--- 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 <xml>Session not authorized to act as user</xml>)
           | _ => 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