4 * This file contains code which relates to authentication of users to Citadel.
23 * Display the login screen
25 void display_login(char *mesg) {
28 printf("HTTP/1.0 200 OK\n");
31 wprintf("<HTML><BODY>\n");
32 wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
34 /* FIX replace with the correct image */
35 wprintf("<IMG SRC=\"/static/velma.gif\">");
36 wprintf("</TD><TD><CENTER>\n");
39 wprintf("<font size=+1><b>%s</b></font>", mesg);
42 serv_puts("MESG hello");
44 if (buf[0]=='1') fmout(NULL);
47 wprintf("</CENTER></TD></TR></TABLE></CENTER>\n");
50 /* FIX add instructions here */
51 wprintf("<CENTER><FORM ACTION=\"/login\" METHOD=\"POST\">\n");
52 wprintf("<TABLE border><TR>\n");
53 wprintf("<TD>User Name:</TD>\n");
54 wprintf("<TD><INPUT TYPE=\"text\" NAME=\"name\" MAXLENGTH=\"25\">\n");
55 wprintf("</TD></TR><TR>\n");
56 wprintf("<TD>Password:</TD>\n");
57 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"pass\" MAXLENGTH=\"20\"></TD>\n");
58 wprintf("</TR></TABLE>\n");
59 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Login\">\n");
60 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"New User\">\n");
61 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
62 wprintf("</FORM></CENTER>\n");
63 wprintf("</BODY></HTML>\n");
71 * This function needs to get called whenever a PASS or NEWU succeeds
73 void become_logged_in(char *user, char *pass, char *serv_response) {
75 extract(wc_username, &serv_response[4], 0);
76 strcpy(wc_password, pass);
77 axlevel = extract_int(&serv_response[4], 1);
78 if (axlevel >=6) is_aide = 1;
79 fprintf(stderr, "become_logged_in(%s,%s)\n", user, pass);
86 if (!strcasecmp(bstr("action"), "Exit")) {
90 if (!strcasecmp(bstr("action"), "Login")) {
91 serv_printf("USER %s", bstr("name"));
94 serv_printf("PASS %s", bstr("pass"));
97 become_logged_in(bstr("name"),
101 display_login(&buf[4]);
106 display_login(&buf[4]);
111 if (!strcasecmp(bstr("action"), "New User")) {
112 serv_printf("NEWU %s", bstr("name"));
115 become_logged_in(bstr("name"), bstr("pass"), buf);
116 serv_printf("SETP %s", bstr("pass"));
120 display_login(&buf[4]);
126 output_static("frameset.html");
129 display_login("Your password was not accepted.");
134 void do_welcome(void) {
135 printf("HTTP/1.0 200 OK\n");
137 wprintf("<HTML><BODY>\n");
138 wprintf("<CENTER><H1>");
139 escputs(wc_username);
141 /* FIX add user stats here */
144 /* FIX --- what should we put here? the main menu,
145 * or new messages in the lobby?
149 wprintf("</BODY></HTML>\n");
154 void do_logout(void) {
157 strcpy(wc_username, "");
158 strcpy(wc_password, "");
159 strcpy(wc_roomname, "");
163 printf("HTTP/1.0 200 OK\n");
165 printf("X-WebCit-Session: close\n");
167 wprintf("<HTML><HEAD><TITLE>Goodbye</TITLE></HEAD><BODY><CENTER>\n");
169 serv_puts("MESG goodbye");
172 if (buf[0]=='1') fmout(NULL);
173 else wprintf("Goodbye\n");
175 wprintf("<HR><A HREF=\"/\">Log in again</A>\n");
177 wprintf("</CENTER></BODY></HTML>\n");