]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
login popout is working, along with non edge case openID login
[citadel.git] / webcit / auth.c
index 40d12c9a1a970dd74eaa60c9da1ca5a930a2aed8..ff9bd7b975f96c7f292a9ce08b57b74e7b0d59e3 100644 (file)
@@ -313,40 +313,25 @@ void do_openid_login(void)
 {
        char buf[4096];
 
-       if (havebstr("language")) {
-               set_selected_language(bstr("language"));
-               go_selected_language();
-       }
+       snprintf(buf, sizeof buf,
+               "OIDS %s|%s/finalize_openid_login|%s",
+               bstr("openid_url"),
+               ChrPtr(site_prefix),
+               ChrPtr(site_prefix)
+       );
 
-       if (havebstr("exit_action")) {
-               do_logout();
+       serv_puts(buf);
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '2') {
+               syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
+               http_redirect(&buf[4]);
                return;
        }
-       if (havebstr("login_action")) {
-               snprintf(buf, sizeof buf,
-                       "OIDS %s|%s/finalize_openid_login|%s",
-                       bstr("openid_url"),
-                       ChrPtr(site_prefix),
-                       ChrPtr(site_prefix)
-               );
 
-               serv_puts(buf);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '2') {
-                       syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
-                       http_redirect(&buf[4]);
-                       return;
-               }
-               else {
-                       display_login();
-                       return;
-               }
-       }
-
-       /* If we get to this point then something failed. */
-       display_login();
+       convenience_page("770000", _("Error"), &buf[4]);
 }
 
+
 /* 
  * Complete the authentication using OpenID
  * This function handles the positive or negative assertion from the user's Identity Provider
@@ -415,7 +400,8 @@ void finalize_openid_login(void)
                }
        }
 
-       /* If we were already logged in, this was an attempt to associate an OpenID account */
+       /* If we were already logged in, this was an attempt to associate an OpenID account 
+       FIXME put this back in
        if (already_logged_in) {
                display_openids();
                FreeStrBuf(&result);
@@ -425,6 +411,7 @@ void finalize_openid_login(void)
                FreeStrBuf(&logged_in_response);
                return;
        }
+       */
 
        /* If this operation logged us in, either by connecting with an existing account or by
         * auto-creating one using Simple Registration Extension, we're already on our way.
@@ -437,6 +424,7 @@ void finalize_openid_login(void)
         * or conflicts with an existing user.  Either way the user will need to specify a new name.
         */
 
+/*
        else if (!strcasecmp(ChrPtr(result), "verify_only")) {
                putbstr("__claimed_id", claimed_id);
                claimed_id = NULL;
@@ -448,16 +436,29 @@ void finalize_openid_login(void)
                do_template("openid_manual_create", NULL);
                end_burst();
        }
+*/
+
+
 
        /* Did we manage to log in?  If so, continue with the normal flow... */
-       else if (WC->logged_in) {
+       if (WC->logged_in) {
+
+               begin_burst();
+               output_headers(1, 0, 0, 0, 1, 0);
+               do_template("authpopup_finished", NULL);
+               end_burst();
+
+               /* FIXME make all this crap work again
                if (WC->need_regi) {
                        display_reg(1);
                } else {
                        do_welcome();
                }
+               */
+
        } else {
-               display_login();
+               /* maybe do something prettier here? */
+               convenience_page("770000", _("Error"), _("Error") );
        }
 
        FreeStrBuf(&result);
@@ -529,7 +530,7 @@ void do_welcome(void)
        if (StrLength(Buf) == 0) {
                StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0);
        }
-       lprintf(9, "Redirecting to user's start page: %s\n", ChrPtr(Buf));
+       syslog(9, "Redirecting to user's start page: %s\n", ChrPtr(Buf));
        http_redirect(ChrPtr(Buf));
 }
 
@@ -758,7 +759,7 @@ void display_reg(int during_login)
        Buf = NewStrBuf();
        memset(&Room, 0, sizeof(folder));
        if (goto_config_room(Buf, &Room) != 0) {
-               lprintf(9, "display_reg() exiting because goto_config_room() failed\n");
+               syslog(9, "display_reg() exiting because goto_config_room() failed\n");
                if (during_login) {
                        do_welcome();
                }
@@ -774,7 +775,7 @@ void display_reg(int during_login)
        FreeStrBuf(&Buf);
        vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
        if (vcard_msgnum < 0L) {
-               lprintf(9, "display_reg() exiting because locate_user_vcard_in_this_room() failed\n");
+               syslog(9, "display_reg() exiting because locate_user_vcard_in_this_room() failed\n");
                if (during_login) {
                        do_welcome();
                }
@@ -957,7 +958,7 @@ void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
                        hdr->HR.got_auth = AUTH_BASIC;
                }
                else 
-                       lprintf(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
+                       syslog(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
        }
 }
 
@@ -972,7 +973,7 @@ void CheckAuthBasic(ParsedHttpHdrs *hdr)
        StrBufAppendBuf(hdr->HR.plainauth, hdr->HR.user_agent, 0);
        hdr->HR.SessionKey = hashlittle(SKEY(hdr->HR.plainauth), 89479832);
 /*
-       lprintf(1, "CheckAuthBasic: calculated sessionkey %ld\n", 
+       syslog(1, "CheckAuthBasic: calculated sessionkey %ld\n", 
                hdr->HR.SessionKey);
 */
 }