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");
32 wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
33 wprintf("<IMG SRC=\"/image&name=hello\">");
34 wprintf("</TD><TD><CENTER>\n");
37 wprintf("<font size=+1><b>%s</b></font>", mesg);
40 serv_puts("MESG hello");
42 if (buf[0]=='1') fmout(NULL);
45 wprintf("</CENTER></TD></TR></TABLE></CENTER>\n");
49 wprintf("<CENTER><FORM ACTION=\"/login\" METHOD=\"POST\">\n");
50 wprintf("<TABLE border><TR>\n");
51 wprintf("<TD>User Name:</TD>\n");
52 wprintf("<TD><INPUT TYPE=\"text\" NAME=\"name\" MAXLENGTH=\"25\">\n");
53 wprintf("</TD></TR><TR>\n");
54 wprintf("<TD>Password:</TD>\n");
55 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"pass\" MAXLENGTH=\"20\"></TD>\n");
56 wprintf("</TR></TABLE>\n");
57 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Login\">\n");
58 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"New User\">\n");
59 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
60 wprintf("</FORM></CENTER>\n");
63 wprintf("<LI><EM>If you already have an account on %s,",
64 serv_info.serv_humannode);
65 wprintf("</EM> enter your user name\n");
66 wprintf("and password and click \"<TT>Login</TT>.\"<BR>\n");
67 wprintf("<LI><EM>If you are a new user,</EM>\n");
68 wprintf("enter the name and password you wish to use, and click\n");
69 wprintf("\"New User.\"<BR><LI>");
70 wprintf("<EM>Please log off properly when finished.</EM>");
71 wprintf("<LI>You must use a browser that supports <i>frames</i> ");
72 wprintf("and <i>cookies</i>.\n");
73 wprintf("</EM></UL>\n");
75 wprintf("</BODY></HTML>\n");
83 * This function needs to get called whenever a PASS or NEWU succeeds
85 void become_logged_in(char *user, char *pass, char *serv_response) {
87 extract(wc_username, &serv_response[4], 0);
88 strcpy(wc_password, pass);
89 axlevel = extract_int(&serv_response[4], 1);
90 if (axlevel >=6) is_aide = 1;
97 if (!strcasecmp(bstr("action"), "Exit")) {
101 if (!strcasecmp(bstr("action"), "Login")) {
102 serv_printf("USER %s", bstr("name"));
105 serv_printf("PASS %s", bstr("pass"));
108 become_logged_in(bstr("name"),
112 display_login(&buf[4]);
117 display_login(&buf[4]);
122 if (!strcasecmp(bstr("action"), "New User")) {
123 serv_printf("NEWU %s", bstr("name"));
126 become_logged_in(bstr("name"), bstr("pass"), buf);
127 serv_printf("SETP %s", bstr("pass"));
131 display_login(&buf[4]);
137 output_static("frameset.html");
140 display_login("Your password was not accepted.");
145 void do_welcome(void) {
146 printf("HTTP/1.0 200 OK\n");
148 wprintf("<CENTER><H1>");
149 escputs(wc_username);
151 /* FIX add user stats here */
154 /* FIX --- what should we put here? the main menu,
155 * or new messages in the lobby?
159 wprintf("</BODY></HTML>\n");
164 void do_logout(void) {
167 strcpy(wc_username, "");
168 strcpy(wc_password, "");
169 strcpy(wc_roomname, "");
173 printf("HTTP/1.0 200 OK\n");
174 printf("X-WebCit-Session: close\n");
178 serv_puts("MESG goodbye");
181 if (buf[0]=='1') fmout(NULL);
182 else wprintf("Goodbye\n");
184 wprintf("<HR><A HREF=\"/\">Log in again</A>\n");
186 wprintf("</CENTER></BODY></HTML>\n");