]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* Store the language setting in the session cookie instead of as a preference. Resol...
[citadel.git] / webcit / webcit.c
index 4908d44f436f7a93b270d50f5b98142ed98b05ae..5629c9ec124fd471d6a5582912bc03fe7a3681d4 100644 (file)
@@ -157,8 +157,12 @@ void output_headers(       int do_httpheaders,     /* 1 = output HTTP headers
        }
 
        stuff_to_cookie(cookie, 1024, 
-                       WCC->wc_session, WCC->wc_username,
-                       WCC->wc_password, WCC->wc_roomname);
+                       WCC->wc_session,
+                       WCC->wc_username,
+                       WCC->wc_password,
+                       WCC->wc_roomname,
+                       get_selected_language()
+       );
 
        if (unset_cookies) {
                hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
@@ -604,8 +608,8 @@ void session_loop(void)
 
 
        /*
-        * If we're not logged in, but we have HTTP Authentication data,
-        * try logging in to Citadel using that.
+        * If we're not logged in, but we have authentication data (either from
+        * a cookie or from http-auth), try logging in to Citadel using that.
         */
        if ((!WCC->logged_in)
            && (StrLength(WCC->Hdr->c_username) > 0)
@@ -634,24 +638,33 @@ void session_loop(void)
                (WCC->Hdr->eReqType != eHEAD);
 
        /*
-        * If we're not logged in, but we have username and password cookies
-        * supplied by the browser, try using them to log in.
+        * If a 'gotofirst' parameter has been specified, attempt to goto that room
+        * prior to doing anything else.
         */
-       if ((!WCC->logged_in)
-          && (StrLength(WCC->Hdr->c_username)>0)
-          && (StrLength(WCC->Hdr->c_password)>0)) {
-               ReEstablish_Session();
+       if (havebstr("gotofirst")) {
+               int ret;
+               ret = gotoroom(sbstr("gotofirst"));     /* do quietly to avoid session output! */
+               if ((ret/100) != 2) {
+                       lprintf(1, "GOTOFIRST: Unable to change to [%s]; Reason: %d\n",
+                               bstr("gotofirst"), ret);
+               }
        }
 
        /*
-        * If a 'gotofirst' parameter has been specified, attempt to goto that room
-        * prior to doing anything else.
+        * If we aren't in any room yet, but we have cookie data telling us where we're
+        * supposed to be, and 'gotofirst' was not specified, then go there.
         */
-       if (havebstr("gotofirst")) {
+       else if ( (StrLength(WCC->wc_roomname) == 0) && ( (StrLength(WCC->Hdr->c_roomname) > 0) )) {
+               lprintf(9, "We are in '%s' but cookie indicates '%s', going there...\n",
+                       ChrPtr(WCC->wc_roomname),
+                       ChrPtr(WCC->Hdr->c_roomname)
+               );
                int ret;
-               ret = gotoroom(sbstr("gotofirst"));     /* do this quietly to avoid session output! */
-               if (ret != 0)
-                       lprintf(1, "GOTOFIRST: Unable to change to [%s]; Reason: %d\n", bstr("gotofirst"), ret);
+               ret = gotoroom(WCC->Hdr->c_roomname);   /* do quietly to avoid session output! */
+               if ((ret/100) != 2) {
+                       lprintf(1, "COOKIEGOTO: Unable to change to [%s]; Reason: %d\n",
+                               ChrPtr(WCC->Hdr->c_roomname), ret);
+               }
        }
 
        if (WCC->Hdr->Handler != NULL) {
@@ -675,10 +688,6 @@ void session_loop(void)
        }
 
 SKIP_ALL_THIS_CRAP:
-       if (WCC->SavePrefsToServer) {
-               save_preferences();
-               WCC->SavePrefsToServer = 0;
-       }
        FreeStrBuf(&Buf);
        fflush(stdout);
        WCC->Hdr->http_host = NULL;