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 BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
34 wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
35 wprintf("<IMG SRC=\"/image&name=hello\">");
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");
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");
65 wprintf("<LI><EM>If you already have an account on %s,",
66 serv_info.serv_humannode);
67 wprintf("</EM> enter your user name\n");
68 wprintf("and password and click \"<TT>Login</TT>.\"<BR>\n");
69 wprintf("<LI><EM>If you are a new user,</EM>\n");
70 wprintf("enter the name and password you wish to use, and click\n");
71 wprintf("\"New User.\"<BR><LI>");
72 wprintf("<EM>Please log off properly when finished.</EM>");
73 wprintf("<LI>You must use a browser that supports <i>frames</i> ");
74 wprintf("and <i>cookies</i>.\n");
75 wprintf("</EM></UL>\n");
77 wprintf("</BODY></HTML>\n");
85 * This function needs to get called whenever a PASS or NEWU succeeds
87 void become_logged_in(char *user, char *pass, char *serv_response) {
89 extract(wc_username, &serv_response[4], 0);
90 strcpy(wc_password, pass);
91 axlevel = extract_int(&serv_response[4], 1);
92 if (axlevel >=6) is_aide = 1;
93 fprintf(stderr, "become_logged_in(%s,%s)\n", user, pass);
100 if (!strcasecmp(bstr("action"), "Exit")) {
104 if (!strcasecmp(bstr("action"), "Login")) {
105 serv_printf("USER %s", bstr("name"));
108 serv_printf("PASS %s", bstr("pass"));
111 become_logged_in(bstr("name"),
115 display_login(&buf[4]);
120 display_login(&buf[4]);
125 if (!strcasecmp(bstr("action"), "New User")) {
126 serv_printf("NEWU %s", bstr("name"));
129 become_logged_in(bstr("name"), bstr("pass"), buf);
130 serv_printf("SETP %s", bstr("pass"));
134 display_login(&buf[4]);
140 output_static("frameset.html");
143 display_login("Your password was not accepted.");
148 void do_welcome(void) {
149 printf("HTTP/1.0 200 OK\n");
151 wprintf("<HTML><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
152 wprintf("<CENTER><H1>");
153 escputs(wc_username);
155 /* FIX add user stats here */
158 /* FIX --- what should we put here? the main menu,
159 * or new messages in the lobby?
163 wprintf("</BODY></HTML>\n");
168 void do_logout(void) {
171 strcpy(wc_username, "");
172 strcpy(wc_password, "");
173 strcpy(wc_roomname, "");
177 printf("HTTP/1.0 200 OK\n");
179 printf("X-WebCit-Session: close\n");
181 wprintf("<HTML><HEAD><TITLE>Goodbye</TITLE></HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\"><CENTER>\n");
183 serv_puts("MESG goodbye");
186 if (buf[0]=='1') fmout(NULL);
187 else wprintf("Goodbye\n");
189 wprintf("<HR><A HREF=\"/\">Log in again</A>\n");
191 wprintf("</CENTER></BODY></HTML>\n");