]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
* use load_message in the useredit form
[citadel.git] / webcit / auth.c
index 4448d48df132ee8fef9c5a1ba6a1aaf052376c6c..dd240fb09a710464b00e35527c917df0993ed82a 100644 (file)
@@ -91,7 +91,7 @@ void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *usernam
        svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
 
        svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
-                ChrPtr(serv_info.serv_humannode));
+                ChrPtr(WC->serv_info->serv_humannode));
 
        do_template("openid_manual_create", NULL);
        wDumpContent(2);
@@ -116,6 +116,7 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
        wcsession *WCC = WC;
        char buf[SIZ];
        StrBuf *FloorDiv;
+       StrBuf *Language = NULL;
 
        WC->logged_in = 1;
 
@@ -153,7 +154,15 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
                WC->need_vali = extract_int(&buf[4], 2);
                extract_token(WC->cs_inet_email, &buf[4], 3, '|', sizeof WC->cs_inet_email);
        }
-
+       if (havebstr("language"))
+               set_preference("language", NewStrBufDup(SBSTR("language")), 1);
+       else {
+               get_preference("language", &Language);
+               if (Language != NULL) {
+                       set_selected_language(ChrPtr(Language));
+                       go_selected_language();         /* set locale */
+               }
+       }
        get_preference("floordiv_expanded", &FloorDiv);
        WC->floordiv_expanded = FloorDiv;
 }
@@ -231,7 +240,6 @@ void do_login(void)
                }
        }
        if (WCC->logged_in) {
-               set_preference("language", NewStrBufPlain(bstr("language"), -1), 1);
                if (WCC->need_regi) {
                        display_reg(1);
                } else if (WCC->need_vali) {
@@ -375,9 +383,7 @@ void finalize_openid_login(void)
                                serv_puts("000");
 
                                linecount = 0;
-                               while (StrBuf_ServGetln(Buf), 
-                                      (StrLength(Buf)==3) && 
-                                      !strcmp(ChrPtr(Buf), "000")) 
+                               while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) 
                                {
                                        if (linecount == 0) result = NewStrBufDup(Buf);
                                        if (!strcasecmp(ChrPtr(result), "authenticate")) {
@@ -530,16 +536,17 @@ void end_webcit_session(void) {
  */
 void do_logout(void)
 {
+       wcsession *WCC = WC;
        char buf[SIZ];
 
-       FlushStrBuf(WC->wc_username);
-       FlushStrBuf(WC->wc_password);
-       FlushStrBuf(WC->wc_roomname);
-       FlushStrBuf(WC->wc_fullname);
+       FlushStrBuf(WCC->wc_username);
+       FlushStrBuf(WCC->wc_password);
+       FlushStrBuf(WCC->wc_roomname);
+       FlushStrBuf(WCC->wc_fullname);
 
        /* FIXME: this is to suppress the iconbar displaying, because we aren't
           actually logged out yet */
-       WC->logged_in = 0;
+       WCC->logged_in = 0;
        
        /** Calling output_headers() this way causes the cookies to be un-set */
        output_headers(1, 1, 0, 1, 0, 0);
@@ -552,7 +559,7 @@ void do_logout(void)
        serv_puts("MESG goodbye");
        serv_getln(buf, sizeof buf);
 
-       if (WC->serv_sock >= 0) {
+       if (WCC->serv_sock >= 0) {
                if (buf[0] == '1') {
                        fmout("CENTER");
                } else {
@@ -726,6 +733,8 @@ void validate(void)
  */
 void display_reg(int during_login)
 {
+       message_summary *VCMsg;
+       wc_mime_attachment *VCAtt;
        long vcard_msgnum;
 
        if (goto_config_room() != 0) {
@@ -734,7 +743,7 @@ void display_reg(int during_login)
                return;
        }
 
-       vcard_msgnum = locate_user_vcard_in_this_room();
+       vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
        if (vcard_msgnum < 0L) {
                if (during_login) do_welcome();
                else display_main_menu();
@@ -742,10 +751,10 @@ void display_reg(int during_login)
        }
 
        if (during_login) {
-               do_edit_vcard(vcard_msgnum, "1", "do_welcome", USERCONFIGROOM);
+               do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "do_welcome", USERCONFIGROOM);
        }
        else {
-               do_edit_vcard(vcard_msgnum, "1", "display_main_menu", USERCONFIGROOM);
+               do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "display_main_menu", USERCONFIGROOM);
        }
 
 }