* add more module handlers:
[citadel.git] / webcit / auth.c
index dd240fb09a710464b00e35527c917df0993ed82a..7cb7bc83cf7626322c8fd0ecccaa20a8b2e6da03 100644 (file)
@@ -114,11 +114,11 @@ void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *usernam
 void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
 {
        wcsession *WCC = WC;
-       char buf[SIZ];
+       StrBuf *Buf;
        StrBuf *FloorDiv;
        StrBuf *Language = NULL;
 
-       WC->logged_in = 1;
+       WCC->logged_in = 1;
 
        if (WCC->wc_fullname == NULL)
                WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
@@ -146,13 +146,19 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
 
        load_preferences();
 
+       Buf = NewStrBuf();
        serv_puts("CHEK");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '2') {
-               WC->new_mail = extract_int(&buf[4], 0);
-               WC->need_regi = extract_int(&buf[4], 1);
-               WC->need_vali = extract_int(&buf[4], 2);
-               extract_token(WC->cs_inet_email, &buf[4], 3, '|', sizeof WC->cs_inet_email);
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 2) {
+               const char *pch;
+
+               pch = ChrPtr(Buf) + 4;
+               WCC->new_mail  = StrBufExtractNext_long(Buf, &pch, '|');
+               WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
+               WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
+               if (WCC->cs_inet_email == NULL)
+                       WCC->cs_inet_email  = NewStrBuf();
+               StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
        }
        if (havebstr("language"))
                set_preference("language", NewStrBufDup(SBSTR("language")), 1);
@@ -164,7 +170,8 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
                }
        }
        get_preference("floordiv_expanded", &FloorDiv);
-       WC->floordiv_expanded = FloorDiv;
+       WCC->floordiv_expanded = FloorDiv;
+       FreeStrBuf(&Buf);
 }
 
 
@@ -733,16 +740,20 @@ void validate(void)
  */
 void display_reg(int during_login)
 {
+       StrBuf *Buf;
        message_summary *VCMsg;
        wc_mime_attachment *VCAtt;
        long vcard_msgnum;
 
-       if (goto_config_room() != 0) {
+       Buf = NewStrBuf();
+       if (goto_config_room(Buf) != 0) {
                if (during_login) do_welcome();
                else display_main_menu();
+               FreeStrBuf(&Buf);
                return;
        }
 
+       FreeStrBuf(&Buf);
        vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
        if (vcard_msgnum < 0L) {
                if (during_login) do_welcome();
@@ -918,3 +929,17 @@ InitModule_AUTH
 
        return ;
 }
+
+
+void 
+SessionDestroyModule_AUTH
+(wcsession *sess)
+{
+       FreeStrBuf(&sess->wc_username);
+       FreeStrBuf(&sess->wc_fullname);
+       FreeStrBuf(&sess->wc_password);
+       FreeStrBuf(&sess->wc_roomname);
+       FreeStrBuf(&sess->httpauth_user);
+       FreeStrBuf(&sess->httpauth_pass);
+       FreeStrBuf(&sess->cs_inet_email);
+}