summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/squark-filter.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/squark-filter.c b/src/squark-filter.c
index 50b96de..1955a59 100644
--- a/src/squark-filter.c
+++ b/src/squark-filter.c
@@ -416,30 +416,35 @@ static void read_input(struct sqdb *db)
category = 0;
token = authdb_get(&adb, &addr, &entry, 1);
- if (authdb_check_login(token, &entry, username, now, &adbc)) {
- auth_ok = 1;
- username = BLOB_STRLEN(entry.p.login_name);
- } else if ((!adbc.require_auth) ||
- (!blob_is_null(username) && blob_cmp(username, dash) != 0)) {
- auth_ok = 1;
- authdb_clear_entry(&entry);
- memcpy(entry.p.login_name, username.ptr, username.len);
- authdb_commit_login(token, &entry, now, &adbc);
+ if (token == NULL) {
+ /* internal error */
+ send_redirect(BLOB_STR("internal-error.html"), id, url, BLOB_STR("internal_error"), username);
} else {
- auth_ok = 0;
- }
+ if (authdb_check_login(token, &entry, username, now, &adbc)) {
+ auth_ok = 1;
+ username = BLOB_STRLEN(entry.p.login_name);
+ } else if ((!adbc.require_auth) ||
+ (!blob_is_null(username) && blob_cmp(username, dash) != 0)) {
+ auth_ok = 1;
+ authdb_clear_entry(&entry);
+ memcpy(entry.p.login_name, username.ptr, username.len);
+ authdb_commit_login(token, &entry, now, &adbc);
+ } else {
+ auth_ok = 0;
+ }
- if (!auth_ok) {
- send_redirect(BLOB_STR("login.cgi"), id, url, BLOB_STR("auth"), username);
- } else if ((1ULL << category) & entry.p.hard_block_categories) {
- send_redirect(BLOB_STR("blocked.cgi"), id, url, get_category_name(db, category), username);
- } else if (((1ULL << category) & entry.p.block_categories) &&
- (now < entry.override_time ||
- now > entry.override_time + FILTER_OVERRIDE_TIMEOUT)) {
- send_redirect(BLOB_STR("warning.cgi"), id, url, get_category_name(db, category), username);
- } else
- send_ok(id, get_category_name(db, category),
- !!((1ULL << category) & entry.p.block_categories));
+ if (!auth_ok) {
+ send_redirect(BLOB_STR("login.cgi"), id, url, BLOB_STR("auth"), username);
+ } else if ((1ULL << category) & entry.p.hard_block_categories) {
+ send_redirect(BLOB_STR("blocked.cgi"), id, url, get_category_name(db, category), username);
+ } else if (((1ULL << category) & entry.p.block_categories) &&
+ (now < entry.override_time ||
+ now > entry.override_time + FILTER_OVERRIDE_TIMEOUT)) {
+ send_redirect(BLOB_STR("warning.cgi"), id, url, get_category_name(db, category), username);
+ } else
+ send_ok(id, get_category_name(db, category),
+ !!((1ULL << category) & entry.p.block_categories));
+ }
}
if (b.len) {