openid blah blah blah
authorArt Cancro <ajc@citadel.org>
Tue, 3 Jun 2008 16:30:35 +0000 (16:30 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 3 Jun 2008 16:30:35 +0000 (16:30 +0000)
webcit/auth.c
webcit/static/openid_manual_create.html [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index 1eed0591759c0475568abb3d3293b87f2285e55f..25d1e95c75ea84d30789f55769afc71b197d003c 100644 (file)
@@ -152,6 +152,38 @@ void display_openid_login(char *mesg)
 }
 
 
+void display_openid_name_request(char *claimed_id, char *username) {
+       char buf[SIZ];
+
+       output_headers(1, 1, 2, 0, 0, 0);
+       wprintf("<div id=\"login_screen\">\n");
+
+       stresc(buf, sizeof buf, claimed_id, 0, 0);
+       svprintf(HKEY("VERIFIED"), WCS_STRING, _("Your OpenID <tt>%s</tt> was successfully verified."),
+               claimed_id);
+
+       if (!IsEmptyStr(username)) {
+               stresc(buf, sizeof buf, username, 0, 0);
+               svprintf(HKEY("REASON"), WCS_STRING,
+                       _("However, the user name '%s' conflicts with an existing user."), username);
+       }
+       else {
+               svput("REASON", WCS_STRING, "");
+       }
+
+       svput("ACTION_REQUESTED", WCS_STRING, _("Please specify the user name you would like to use."));
+
+       svput("USERNAME_BOX", WCS_STRING, _("User name:"));
+       svput("NEWUSER_BUTTON", WCS_STRING, _("New User"));
+       svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
+
+       svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
+               serv_info.serv_humannode);
+
+       do_template("openid_manual_create");
+       wDumpContent(2);
+}
+
 
 
 /* Initialize the session
@@ -260,6 +292,44 @@ void do_login(void)
 
 }
 
+/* 
+ * Try to create an account manually after an OpenID was verified
+ */
+void openid_manual_create(void)
+{
+       if (havebstr("exit_action")) {
+               do_logout();
+               return;
+       }
+
+#if 0 
+       char buf[SIZ];
+       if (havebstr("newuser_action")) {
+               serv_printf("OIDC %s", bstr("name"));
+               serv_getln(buf, sizeof buf);
+               if (buf[0] == '2') {
+                       become_logged_in(bstr("name"), bstr("pass"), buf);              // FIXME
+               } else {
+                       display_openid_name_request(char *claimed_id, char *username);  // FIXME
+                       return;
+               }
+       }
+#endif
+
+       if (WC->logged_in) {
+               if (WC->need_regi) {
+                       display_reg(1);
+               } else if (WC->need_vali) {
+                       validate();
+               } else {
+                       do_welcome();
+               }
+       } else {
+               display_login(_("Your password was not accepted."));
+       }
+
+}
+
 
 /* 
  * Perform authentication using OpenID
@@ -317,6 +387,7 @@ void finalize_openid_login(void)
        char username[128] = "";
        char password[128] = "";
        char logged_in_response[1024] = "";
+       char claimed_id[1024] = "";
 
        if (havebstr("openid.mode")) {
                if (!strcasecmp(bstr("openid.mode"), "id_res")) {
@@ -356,6 +427,14 @@ void finalize_openid_login(void)
                                                                sizeof logged_in_response);
                                                }
                                        }
+                                       else if (!strcasecmp(result, "verify_only")) {
+                                               if (linecount == 1) {
+                                                       safestrncpy(claimed_id, buf, sizeof claimed_id);
+                                               }
+                                               if (linecount == 2) {
+                                                       safestrncpy(username, buf, sizeof username);
+                                               }
+                                       }
                                        ++linecount;
                                }
                        }
@@ -375,7 +454,13 @@ void finalize_openid_login(void)
                become_logged_in(username, password, logged_in_response);
        }
 
-       /* FIXME -- right here we have to put the code to log in a new user */
+       /* The specified OpenID was verified but the desired user name was either not specified via SRI
+        * or conflicts with an existing user.  Either way the user will need to specify a new name.
+        */
+
+       else if (!strcasecmp(result, "verify_only")) {
+               display_openid_name_request(claimed_id, username);
+       }
 
        /* Did we manage to log in?  If so, continue with the normal flow... */
        if (WC->logged_in) {
diff --git a/webcit/static/openid_manual_create.html b/webcit/static/openid_manual_create.html
new file mode 100644 (file)
index 0000000..2f46070
--- /dev/null
@@ -0,0 +1,17 @@
+<?=beginbox>
+<?HELLO>
+<div class="login_infos">
+       <img src="static/openid-small.gif"><?VERIFIED><br />
+       <?REASON><br />
+       <?ACTION_REQUESTED><br />
+</div>
+<form action="openid_manual_create" method="POST"  class="box" id="login_form">
+        <label for="uname"><?USERNAME_BOX></label>
+        <input type="text" name="name" id="uname" > <br>
+        <div class="logbuttons">
+        <input type="submit" name="newuser_action" value="<?NEWUSER_BUTTON>" class="logbutton" >
+        <input type="submit" name="exit_action" value="<?EXIT_BUTTON>"  class="logbutton">
+        <br>
+        </div>
+</form>
+<?=endbox>
index 549d8b0da7960f09c1e2194fcd2becb87bb2d4bd..68f6777af169f572c074604b09cf43b123d5951a 100644 (file)
@@ -1720,6 +1720,8 @@ void session_loop(struct httprequest *req)
                do_openid_login();
        } else if (!strcasecmp(action, "finalize_openid_login")) {
                finalize_openid_login();
+       } else if (!strcasecmp(action, "openid_manual_create")) {
+               openid_manual_create();
        } else if (!WC->logged_in) {
                display_login(NULL);
        }
index a054ea9dac30bb7a8065e1e11e3cf045d9985f3f..44ee9dfd400a847ac29ece770cdfa50a8e73b775 100644 (file)
@@ -487,6 +487,7 @@ void become_logged_in(char *, char *, char *);
 void do_login(void);
 void do_openid_login(void);
 void finalize_openid_login(void);
+void openid_manual_create(void);
 void display_login(char *mesg);
 void display_openid_login(char *mesg);
 void display_openids(void);