changeset 5:443f27cd1572

Detecting cancellation
author Adam Chlipala <adam@chlipala.net>
date Sun, 26 Dec 2010 17:36:07 -0500
parents 2d409aff8800
children 99496175078b
files src/ur/openid.ur
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ur/openid.ur	Sun Dec 26 17:19:52 2010 -0500
+++ b/src/ur/openid.ur	Sun Dec 26 17:36:07 2010 -0500
@@ -52,9 +52,16 @@
         case OpenidFfi.getOutput os "openid.error" of
             Some v => error <xml>Authentication failed: {[v]}</xml>
           | None =>
-            case OpenidFfi.getOutput os "openid.identity" of
-                None => error <xml>Missing identity in OP response</xml>
-              | Some v => return <xml>Identity: {[v]}</xml>
+            case OpenidFfi.getOutput os "openid.mode" of
+                None => error <xml>No <tt>openid.mode</tt> in response</xml>
+              | Some mode =>
+                case mode of
+                    "cancel" => error <xml>You canceled the authentication!</xml>
+                  | "id_res" =>
+                    (case OpenidFfi.getOutput os "openid.identity" of
+                         None => error <xml>Missing identity in OP response</xml>
+                       | Some v => return <xml>Identity: {[v]}</xml>)
+                  | _ => error <xml>Unexpected <tt>openid.mode</tt>: <tt>{[mode]}</tt></xml>
 
 fun authenticate id =
     dy <- discover id;