int (*mod_auth)(const char*, const char*) = (int (*)(const char*, const char*))dlsym((*config->libs)[j]->lib, "mod_auth");
char* usr = mandshurica_parse_form(postbuf, "username");
char* pwd = mandshurica_parse_form(postbuf, "password");
- printf("%s, %s\n", usr == NULL ? "(null)" : usr, pwd == NULL ? "(null)" : pwd);
+ if(usr != NULL && pwd != NULL) {
+ int res = mod_auth(usr, pwd);
+ if(res == MS_AUTH_OK) {
+ } else if(res == MS_AUTH_ERROR) {
+ send(sock, "HTTP/1.1 400 Bad Request\r\n", 17 + 9, 0);
+ send(sock, "Connection: keep-alive\r\n", 24, 0);
+ send(sock, "Content-Length: 0\r\n", 19, 0);
+ send(sock, "\r\n", 2, 0);
+ } else if(res == MS_AUTH_FAIL) {
+
+ send(sock, "HTTP/1.1 403 Forbidden\r\n", 15 + 9, 0);
+ send(sock, "Connection: keep-alive\r\n", 24, 0);
+ send(sock, "Content-Length: 0\r\n", 19, 0);
+ send(sock, "\r\n", 2, 0);
+ }
+ } else {
+ send(sock, "HTTP/1.1 400 Bad Request\r\n", 17 + 9, 0);
+ send(sock, "Connection: keep-alive\r\n", 24, 0);
+ send(sock, "Content-Length: 0\r\n", 19, 0);
+ send(sock, "\r\n", 2, 0);
+ }
sent = true;
}
}