]> code.citadel.org Git - citadel.git/blob - webcit/auth.c
Login page is now static
[citadel.git] / webcit / auth.c
1 /*
2  * auth.c
3  *
4  * This file contains code which relates to authentication of users to Citadel.
5  *
6  */
7
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <stdio.h>
11 #include <ctype.h>
12 #include <string.h>
13 #include <errno.h>
14 #include "webcit.h"
15
16
17 /*
18  * This function needs to get called whenever a PASS or NEWU succeeds
19  */
20 void become_logged_in(char *user, char *pass, char *serv_response) {
21
22         logged_in = 1;
23         strcpy(wc_username, user);
24         strcpy(wc_password, pass);
25         
26         }
27
28
29 void do_login() {
30         char buf[256];
31
32         if (!strcasecmp(bstr("action"), "Login")) {
33                 serv_printf("USER %s", bstr("name"));
34                 serv_gets(buf);
35                 if (buf[0]=='3') {
36                         serv_printf("PASS %s", bstr("pass"));
37                         serv_gets(buf);
38                         if (buf[0]=='2') {
39                                 become_logged_in(bstr("name"), bstr("pass"), buf);
40                                 }
41                         }
42                 }
43
44         if (logged_in) {
45                 output_static("frameset.html");
46                 }
47         else {
48                 printf("HTTP/1.0 200 OK\n");
49                 output_headers();
50                 wprintf("<HTML><HEAD><TITLE>Nope</TITLE></HEAD><BODY>\n");
51                 wprintf("Your password was not accepted.\n");
52                 wprintf("<HR><A HREF=\"/\">Try again</A>\n");
53                 wprintf("</BODY></HTML>\n");
54                 wDumpContent();
55                 }
56
57         }