4 * This file contains code which relates to authentication of users to Citadel.
31 * Display the login screen
33 void display_login(char *mesg) {
36 printf("HTTP/1.0 200 OK\n");
40 wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
41 wprintf("<IMG SRC=\"/image&name=hello\">");
42 wprintf("</TD><TD><CENTER>\n");
45 wprintf("<font size=+1><b>%s</b></font>", mesg);
48 serv_puts("MESG hello");
50 if (buf[0]=='1') fmout(NULL);
53 wprintf("</CENTER></TD></TR></TABLE></CENTER>\n");
57 wprintf("<CENTER><FORM ACTION=\"/login\" METHOD=\"POST\">\n");
58 wprintf("<TABLE border><TR>\n");
59 wprintf("<TD>User Name:</TD>\n");
60 wprintf("<TD><INPUT TYPE=\"text\" NAME=\"name\" MAXLENGTH=\"25\">\n");
61 wprintf("</TD></TR><TR>\n");
62 wprintf("<TD>Password:</TD>\n");
63 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"pass\" MAXLENGTH=\"20\"></TD>\n");
64 wprintf("</TR></TABLE>\n");
65 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Login\">\n");
66 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"New User\">\n");
67 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
68 wprintf("</FORM></CENTER>\n");
71 wprintf("<LI><EM>If you already have an account on %s,",
72 serv_info.serv_humannode);
73 wprintf("</EM> enter your user name\n");
74 wprintf("and password and click \"<TT>Login</TT>.\"<BR>\n");
75 wprintf("<LI><EM>If you are a new user,</EM>\n");
76 wprintf("enter the name and password you wish to use, and click\n");
77 wprintf("\"New User.\"<BR><LI>");
78 wprintf("<EM>Please log off properly when finished.</EM>");
79 wprintf("<LI>You must use a browser that supports <i>frames</i> ");
80 wprintf("and <i>cookies</i>.\n");
81 wprintf("</EM></UL>\n");
83 wprintf("</BODY></HTML>\n");
91 * This function needs to get called whenever a PASS or NEWU succeeds
93 void become_logged_in(char *user, char *pass, char *serv_response) {
95 extract(wc_username, &serv_response[4], 0);
96 strcpy(wc_password, pass);
97 axlevel = extract_int(&serv_response[4], 1);
98 if (axlevel >=6) is_aide = 1;
102 void do_login(void) {
105 if (!strcasecmp(bstr("action"), "Exit")) {
109 if (!strcasecmp(bstr("action"), "Login")) {
110 serv_printf("USER %s", bstr("name"));
113 serv_printf("PASS %s", bstr("pass"));
116 become_logged_in(bstr("name"),
120 display_login(&buf[4]);
125 display_login(&buf[4]);
130 if (!strcasecmp(bstr("action"), "New User")) {
131 serv_printf("NEWU %s", bstr("name"));
134 become_logged_in(bstr("name"), bstr("pass"), buf);
135 serv_printf("SETP %s", bstr("pass"));
139 display_login(&buf[4]);
145 output_static("frameset.html");
148 display_login("Your password was not accepted.");
153 void do_welcome(void) {
154 printf("HTTP/1.0 200 OK\n");
156 wprintf("<CENTER><H1>");
157 escputs(wc_username);
159 /* FIX add user stats here */
162 /* FIX --- what should we put here? the main menu,
163 * or new messages in the lobby?
167 wprintf("</BODY></HTML>\n");
172 void do_logout(void) {
175 strcpy(wc_username, "");
176 strcpy(wc_password, "");
177 strcpy(wc_roomname, "");
181 printf("HTTP/1.0 200 OK\n");
182 printf("X-WebCit-Session: close\n");
186 serv_puts("MESG goodbye");
189 if (buf[0]=='1') fmout(NULL);
190 else wprintf("Goodbye\n");
192 wprintf("<HR><A HREF=\"/\">Log in again</A>\n");
194 wprintf("</CENTER></BODY></HTML>\n");
207 void validate(void) {
213 printf("HTTP/1.0 200 OK\n");
216 strcpy(buf,bstr("user"));
217 if (strlen(buf)>0) if (strlen(bstr("axlevel"))>0) {
218 serv_printf("VALI %s|%s",buf,bstr("axlevel"));
221 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
229 wprintf("<EM>%s</EM><BR></BODY></HTML>\n", &buf[4]);
234 strcpy(user,&buf[4]);
235 serv_printf("GREG %s",user);
242 if (a==1) wprintf("User #%s<BR><H1>%s</H1>",
244 if (a==2) wprintf("PW: %s<BR>\n",buf);
245 if (a==3) wprintf("%s<BR>\n",buf);
246 if (a==4) wprintf("%s<BR>\n",buf);
247 if (a==5) wprintf("%s, ",buf);
248 if (a==6) wprintf("%s ",buf);
249 if (a==7) wprintf("%s<BR>\n",buf);
250 if (a==8) wprintf("%s<BR>\n",buf);
251 if (a==9) wprintf("Current access level: %d (%s)\n",
252 atoi(buf),axdefs[atoi(buf)]);
253 } while(strcmp(buf,"000"));
256 wprintf("<H1>%s</H1>%s<BR>\n",user,&cmd[4]);
259 wprintf("<CENTER><TABLE border><CAPTION>Select access level:");
260 wprintf("</CAPTION><TR>");
261 for (a=0; a<=6; ++a) {
263 "<TD><A HREF=\"/validate&user=%s&axlevel=%d\">%s</A></TD>\n",
264 urlesc(user), a, axdefs[a]);
266 wprintf("</TR></TABLE><CENTER><BR>\n");