Change auth to allow multiple logins
[blerg.git] / cgi / cgi_blerg.c
index 664d6a5..b479535 100644 (file)
@@ -307,12 +307,12 @@ int main(int argc, char *argv[]) {
                        exit(0);
                }
 
-               if (!auth_login(username, password)) {
+               char *token = auth_login(username, password);
+               if (token == NULL) {
                        respond_JSON_Failure();
                        exit(0);
                }
 
-               char *token = auth_get_token(username);
                printf("Set-Cookie: auth=%s\r\n", token);
                free(token);
 
@@ -327,7 +327,8 @@ int main(int argc, char *argv[]) {
                if (!check_auth(username))
                        exit(0);
 
-               auth_logout(username);
+               const char *given_token = cgi_getcookie("auth");
+               auth_logout(username, given_token);
                respond_JSON_Success();
        } else if (strncmp(path, "/subscribe", 10) == 0 || strncmp(path, "/unsubscribe", 12) == 0) {
                const char *username = cgi_getentrystr("username");