]> code.citadel.org Git - citadel.git/blobdiff - webcit/auth.c
* wDumpContent() is now responsible for </BODY></HTML> most of the
[citadel.git] / webcit / auth.c
index b865ab7cf019a7783af7f0e9feb58d03cbbc0450..24fc878f0cfdaaacea1743625aeebe939bebe678 100644 (file)
@@ -34,7 +34,7 @@ void display_login(char *mesg) {
        char buf[256];
 
        printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
+       output_headers(1, "_top");
 
        /* Da banner */
        wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
@@ -65,6 +65,9 @@ void display_login(char *mesg) {
        wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Login\">\n");
         wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"New User\">\n");
         wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
+       
+       wprintf("<BR><INPUT TYPE=\"checkbox\" NAME=\"noframes\">");
+       wprintf("<FONT SIZE=-1>Check here to disable frames</FONT>\n");
         wprintf("</FORM></CENTER>\n");
 
        /* Da instructions */
@@ -80,8 +83,7 @@ void display_login(char *mesg) {
        wprintf("and <i>cookies</i>.\n");
        wprintf("</EM></UL>\n");
 
-       wprintf("</BODY></HTML>\n");
-       wDumpContent();
+       wDumpContent(1);
        }
 
 
@@ -103,6 +105,12 @@ void do_login(void) {
        char buf[256];
        int need_regi = 0;
 
+
+       if (!strcasecmp(bstr("noframes"), "on"))
+               noframes = 1;
+       else
+               noframes = 0;
+
        if (!strcasecmp(bstr("action"), "Exit")) {
                do_logout();
                }
@@ -153,7 +161,7 @@ void do_login(void) {
                        display_reg(1);
                        }
                else {
-                       output_static("frameset.html");
+                       do_welcome();
                        }
                }
        else {
@@ -163,21 +171,27 @@ void do_login(void) {
        }
 
 void do_welcome(void) {
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
-       wprintf("<CENTER><H1>");
-       escputs(wc_username);
-       wprintf("</H1>\n");
-       /* FIX add user stats here */
-
-       wprintf("<HR>");
-       /* FIX  ---  what should we put here?  the main menu,
-        * or new messages in the lobby?
-        */
-       embed_main_menu();
-
-       wprintf("</BODY></HTML>\n");
-       wDumpContent();
+
+
+       fprintf(stderr, "DO_WELCOME CALLED, NOFRAMES=%d\n", noframes);
+
+       if (noframes) {
+               printf("HTTP/1.0 200 OK\n");
+               output_headers(1, "_top");
+               wprintf("<CENTER><H1>");
+               escputs(wc_username);
+               wprintf("</H1>\n");
+               /* FIX add user stats here */
+       
+               wprintf("<HR>");
+               embed_main_menu();
+       
+               wDumpContent(1);
+               }
+
+       else {
+               output_static("frameset.html");
+               }
        }
 
 
@@ -187,12 +201,9 @@ void do_logout(void) {
        strcpy(wc_username, "");
        strcpy(wc_password, "");
        strcpy(wc_roomname, "");
-       strcpy(wc_host, "");
-       strcpy(wc_port, "");
 
        printf("HTTP/1.0 200 OK\n");
-       printf("X-WebCit-Session: close\n");
-       output_headers(1);
+       output_headers(2, "_top");      /* note "2" causes cookies to be unset */
 
        wprintf("<CENTER>");    
        serv_puts("MESG goodbye");
@@ -201,9 +212,8 @@ void do_logout(void) {
        if (buf[0]=='1') fmout(NULL);
        else wprintf("Goodbye\n");
 
-       wprintf("<HR><A HREF=\"/\">Log in again</A>\n");
-       wprintf("</CENTER></BODY></HTML>\n");
-       wDumpContent();
+       wprintf("<HR><A HREF=\"/\">Log in again</A></CENTER>\n");
+       wDumpContent(1);
        serv_puts("QUIT");
        exit(0);
        }
@@ -222,7 +232,7 @@ void validate(void) {
        int a;
 
        printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
+       output_headers(1, "bottom");
 
        strcpy(buf,bstr("user"));
        if (strlen(buf)>0) if (strlen(bstr("axlevel"))>0) {
@@ -237,8 +247,8 @@ void validate(void) {
        serv_gets(buf);
 
        if (buf[0]!='3') {
-               wprintf("<EM>%s</EM><BR></BODY></HTML>\n", &buf[4]);
-               wDumpContent();
+               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               wDumpContent(1);
                return;
                }
 
@@ -275,7 +285,7 @@ void validate(void) {
                        urlesc(user), a, axdefs[a]);
                }
        wprintf("</TR></TABLE><CENTER><BR>\n");
-       wDumpContent();
+       wDumpContent(1);
        }
 
 
@@ -293,7 +303,7 @@ void display_reg(int during_login) {
        int a;
 
        printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
+       output_headers(1, "bottom");
 
         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
@@ -342,8 +352,8 @@ void display_reg(int during_login) {
                }
        wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Register\">\n");
        wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
-       wprintf("</CENTER></BODY></HTML>\n");
-       wDumpContent();
+       wprintf("</CENTER>\n");
+       wDumpContent(1);
        }
 
 /*
@@ -373,9 +383,70 @@ void register_user(void) {
        serv_puts("000");
        
        if (atoi(bstr("during_login"))) {
-               output_static("frameset.html");
+               do_welcome();
                }
        else {
                display_error("Registration information has been saved.");
                }
        }
+
+
+
+
+
+/* 
+ * display form for changing your password
+ */
+void display_changepw(void) {
+       char buf[256];
+
+       printf("HTTP/1.0 200 OK\n");
+       output_headers(1, "bottom");
+
+        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+        wprintf("<B>Change your password</B>\n");
+        wprintf("</FONT></TD></TR></TABLE>\n");
+
+       wprintf("<CENTER>");
+       serv_puts("MESG changepw");
+       serv_gets(buf);
+       if (buf[0]=='1') fmout(NULL);
+
+       wprintf("<FORM ACTION=\"changepw\" METHOD=\"POST\">\n");
+       wprintf("<CENTER><TABLE border><TR><TD>Enter new password:</TD>\n");
+       wprintf("<TD><INPUT TYPE=\"password\" NAME=\"newpass1\" VALUE=\"\" MAXLENGTH=\"20\"></TD></TR>\n");
+       wprintf("<TR><TD>Enter it again to confirm:</TD>\n");
+       wprintf("<TD><INPUT TYPE=\"password\" NAME=\"newpass2\" VALUE=\"\" MAXLENGTH=\"20\"></TD></TR>\n");
+       wprintf("</TABLE>\n");  
+       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Change\">\n");
+       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
+       wprintf("</CENTER>\n");
+       wDumpContent(1);
+       }
+
+/*
+ * change password
+ */
+void changepw(void) {
+       char buf[256];
+       char newpass1[32], newpass2[32];
+       
+       if (strcmp(bstr("action"),"Change")) {
+               display_error("Cancelled.  Password was not changed.");
+               return;
+               }
+
+       strcpy(newpass1, bstr("newpass1"));
+       strcpy(newpass2, bstr("newpass2"));
+
+       if (strcasecmp(newpass1, newpass2)) {
+               display_error("They don't match.  Password was not changed.");
+               return;
+               }
+
+       serv_printf("SETP %s", newpass1);
+       serv_gets(buf);
+       if (buf[0]=='2') display_success(&buf[4]);
+       else display_error(&buf[4]);
+       }