comparison 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
comparison
equal deleted inserted replaced
47:ba203b170476 50:328a429dfedb
88 if b then 88 if b then
89 return M.afterLogout 89 return M.afterLogout
90 else 90 else
91 currentUrl 91 currentUrl
92 92
93 val current = 93 fun current' tweakSession =
94 login <- getCookie auth; 94 login <- getCookie auth;
95 case login of 95 case login of
96 Some (LoggedIn login) => 96 Some (LoggedIn login) =>
97 (ident <- oneOrNoRowsE1 (SELECT (session.Identifier) 97 (ident <- oneOrNoRowsE1 (SELECT (session.Identifier)
98 FROM session 98 FROM session
105 valid <- oneRowE1 (SELECT COUNT( * ) > 0 105 valid <- oneRowE1 (SELECT COUNT( * ) > 0
106 FROM identity 106 FROM identity
107 WHERE identity.User = {[login.User]} 107 WHERE identity.User = {[login.User]}
108 AND identity.Identifier = {[ident]}); 108 AND identity.Identifier = {[ident]});
109 if valid then 109 if valid then
110 tweakSession login.Session;
110 return (Some login.User) 111 return (Some login.User)
111 else 112 else
112 error <xml>Session not authorized to act as user</xml>) 113 error <xml>Session not authorized to act as user</xml>)
113 | _ => return None 114 | _ => return None
115
116 val current = current' (fn _ => return ())
117
118 val renew = current' (fn id =>
119 now <- now;
120 dml (UPDATE session
121 SET Expires = {[addSeconds now M.sessionLifetime]}
122 WHERE Id = {[id]}))
114 123
115 fun validUser s = String.length s > 0 && String.length s < 20 124 fun validUser s = String.length s > 0 && String.length s < 20
116 && String.all Char.isAlnum s 125 && String.all Char.isAlnum s
117 126
118 fun main wrap = 127 fun main wrap =