]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
* Store the language setting in the session cookie instead of as a preference. Resol...
[citadel.git] / webcit / auth.c
index c38bbd51bf67c23ebc004d413fd38d6dfbe7109e..3704061f7f4c8ae61402aea8c1987de079848872 100644 (file)
@@ -28,43 +28,6 @@ void initialize_axdefs(void) {
        axdefs[6] = _("Aide");          /* chief */
 }
 
-int ReEstablish_Session(void)
-{
-       StrBuf *Buf = NewStrBuf();
-       wcsession *WCC = WC;
-
-       serv_printf("USER %s", ChrPtr(WCC->Hdr->c_username));
-       StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) == 3) {
-               serv_printf("PASS %s", ChrPtr(WCC->Hdr->c_password));
-               StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) == 2) {
-                       become_logged_in(WCC->Hdr->c_username, 
-                                        WCC->Hdr->c_password, Buf);
-                       get_preference("default_header_charset", &WCC->DefaultCharset);
-               }
-       }
-       /*
-        * If we don't have a current room, but a cookie specifying the
-        * current room is supplied, make an effort to go there.
-        */
-       if ((StrLength(WCC->wc_roomname) == 0) && (StrLength(WCC->Hdr->c_roomname) > 0)) {
-               serv_printf("GOTO %s", 
-                           ChrPtr(WCC->Hdr->c_roomname));
-               StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) == 2) {
-                       if (WCC->wc_roomname == NULL) {
-                               WCC->wc_roomname = NewStrBufDup(WCC->Hdr->c_roomname);
-                       }
-                       else {
-                               FlushStrBuf(WCC->wc_roomname);
-                               StrBufAppendBuf(WCC->wc_roomname, WCC->Hdr->c_roomname, 0);
-                       }
-               }
-       }
-       FreeStrBuf(&Buf);
-       return 0;
-}
 
 
 /* 
@@ -153,7 +116,6 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
        wcsession *WCC = WC;
        StrBuf *Buf;
        StrBuf *FloorDiv;
-       StrBuf *Language = NULL;
 
        WCC->logged_in = 1;
 
@@ -197,15 +159,6 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
                        WCC->cs_inet_email  = NewStrBuf();
                StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
        }
-       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);
        WCC->floordiv_expanded = FloorDiv;
        FreeStrBuf(&Buf);
@@ -220,6 +173,8 @@ void do_login(void)
        wcsession *WCC = WC;
        StrBuf *Buf;
 
+       lprintf(9, "SELECTED LANGUAGE: '%s'\n", bstr("language"));
+
        if (havebstr("language")) {
                set_selected_language(bstr("language"));
                go_selected_language();
@@ -971,6 +926,7 @@ void CheckAuthBasic(ParsedHttpHdrs *hdr)
        if (hdr->DontNeedAuth)
                return;
 */
+       StrBufAppendBufPlain(hdr->plainauth, HKEY(":"), 0);
        StrBufAppendBuf(hdr->plainauth, hdr->user_agent, 0);
        hdr->SessionKey = hashlittle(SKEY(hdr->plainauth), 89479832);
        
@@ -995,13 +951,13 @@ void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
        if (hdr->DontNeedAuth)
                return;
 */
-       hdr->RawCookie = Line;
-
-       pch = strstr(ChrPtr(hdr->RawCookie), "webcit=");
-       
-       if (pch != NULL)
-               StrBufCutLeft(hdr->RawCookie, (pch - ChrPtr(hdr->RawCookie)) + 7);
+       pch = strstr(ChrPtr(Line), "webcit=");
+       if (pch == NULL) {
+               return;
+       }
 
+       hdr->RawCookie = Line;
+       StrBufCutLeft(hdr->RawCookie, (pch - ChrPtr(hdr->RawCookie)) + 7);
        StrBufDecodeHex(hdr->RawCookie);
 
        if (hdr->c_username == NULL)
@@ -1010,10 +966,14 @@ void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
                hdr->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
        if (hdr->c_roomname == NULL)
                hdr->c_roomname = NewStrBuf();
+       if (hdr->c_language == NULL)
+               hdr->c_language = NewStrBuf();
        cookie_to_stuff(Line, &hdr->desired_session,
                        hdr->c_username,
                        hdr->c_password,
-                       hdr->c_roomname);
+                       hdr->c_roomname,
+                       hdr->c_language
+       );
        hdr->got_auth = AUTH_COOKIE;
 }