X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=http%2Fhttp_blerg.c;h=8a5b9a506c49bf82bf3752634f296ae44276a2d2;hb=948ce5be6ef6bba36edfb544565ca22e316afb0a;hp=85a1e5be0cb3ac13c7d6ed73ae91c98d5b6f652f;hpb=e6a64bc8dc8922623aa8268af0f4a07cc149fdf3;p=blerg.git diff --git a/http/http_blerg.c b/http/http_blerg.c index 85a1e5b..8a5b9a5 100644 --- a/http/http_blerg.c +++ b/http/http_blerg.c @@ -294,7 +294,6 @@ struct MHD_Response *create_response_for_range(struct blerg *b, uint64_t from, u uint64_t record_count = blerg_get_record_count(b); if (from > to || from >= record_count || to >= record_count || to - from > 99) { - blerg_close(b); free(gs); return NULL; } @@ -521,12 +520,12 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c if (as->username[0] == 0 || as->password[0] == 0) return respond_JSON_Failure(connection); - if (!auth_login(as->username, as->password)) + char *token = auth_login(as->username, as->password); + if (token == NULL) return respond_JSON_Failure(connection); response = MHD_create_response_from_data(strlen(JSON_SUCCESS), JSON_SUCCESS, MHD_NO, MHD_NO); - char *token = auth_get_token(as->username); data = malloc(512); snprintf(data, 512, "auth=%s", token); MHD_add_response_header(response, "Set-Cookie", data); @@ -548,7 +547,8 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c struct auth_state *as = (struct auth_state *) *ptr; - auth_logout(as->username); + const char *given_token = MHD_lookup_connection_value(connection, MHD_COOKIE_KIND, "auth"); + auth_logout(as->username, given_token); return respond_JSON_Success(connection); } else if (strncmp(url, "/subscribe", 10) == 0 || strncmp(url, "/unsubscribe", 12) == 0) { ret = process_and_check_auth(connection, method, upload_data, upload_data_size, ptr);