]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
*** empty log message ***
[citadel.git] / webcit / auth.c
index a837c275f4e6884b2eeec9d2aaff8fcdbf0c1855..b7d6b64a27de109be3f0479a57012f28b06ea5a2 100644 (file)
@@ -154,15 +154,47 @@ void do_login(void)
 
 void do_welcome(void)
 {
-       char startpage[SIZ];
+       char buf[SIZ];
+       FILE *fp;
+       int i;
+
+       /*
+        * See if we have to run the first-time setup wizard
+        */
+       if (!setup_wizard) {
+               sprintf(wizard_filename, "setupwiz.%s.%s", ctdlhost, ctdlport);
+               for (i=0; i<strlen(wizard_filename); ++i) {
+                       if (    (wizard_filename[i]==' ')
+                               || (wizard_filename[i] == '/')
+                       ) {
+                               wizard_filename[i] = '_';
+                       }
+               }
+
+               fp = fopen(wizard_filename, "r");
+               if (fp != NULL) {
+                       fgets(buf, sizeof buf, fp);
+                       buf[strlen(buf)-1] = 0;
+                       fclose(fp);
+                       if (atoi(buf) != serv_info.serv_rev_level) {
+                               setup_wizard = 1;       /* already run */
+                       }
+               }
+       }
 
-       get_preference("startpage", startpage);
-       if (strlen(startpage)==0) {
-               strcpy(startpage, "/dotskip&room=_BASEROOM_");
-               set_preference("startpage", startpage);
+       if (!setup_wizard) {
+               http_redirect("/setup_wizard");
        }
 
-       http_redirect(startpage);
+       /*
+        * Go to the user's preferred start page
+        */
+       get_preference("startpage", buf);
+       if (strlen(buf)==0) {
+               strcpy(buf, "/dotskip&room=_BASEROOM_");
+               set_preference("startpage", buf);
+       }
+       http_redirect(buf);
 }