Mercurial > urweb
diff tests/cookieJsec.ur @ 736:796e42c93c48
Cookie signatures for RPCs
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 23 Apr 2009 16:13:02 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/cookieJsec.ur Thu Apr 23 16:13:02 2009 -0400 @@ -0,0 +1,27 @@ +table t : {Id : int} + +cookie c : int + +fun setter r = + setCookie c (readError r.Id); + return <xml>Done</xml> + +fun writer () = + ido <- getCookie c; + case ido of + None => error <xml>No cookie</xml> + | Some id => dml (INSERT INTO t (Id) VALUES ({[id]})) + +fun preWriter () = return <xml><body onload={onConnectFail (alert "RPC error")}> + <button onclick={writer ()} value="Write to database"/> + + <a link={main ()}>Back</a> +</body></xml> + +and main () = return <xml><body> + <form> + <textbox{#Id}/> <submit value="Get cookie" action={setter}/> + </form> + + <form><submit action={preWriter} value="Prepare to write to database"/></form> +</body></xml>