aboutsummaryrefslogtreecommitdiff
path: root/src/routes/handler-info.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-11-17 09:57:09 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-11-17 09:57:09 +0100
commite95cf5c7b6a08eb560763d5167fbddc1c2117bcc (patch)
tree2f7815c9f39328fcaced2113de727f63e4837fa3 /src/routes/handler-info.zig
parent0016aaa197697ec5ff38dfb3f63ac8b6f74b48e0 (diff)
add file uploading and multi-threading
Diffstat (limited to 'src/routes/handler-info.zig')
-rw-r--r--src/routes/handler-info.zig34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/routes/handler-info.zig b/src/routes/handler-info.zig
index 7b744d2..94d0491 100644
--- a/src/routes/handler-info.zig
+++ b/src/routes/handler-info.zig
@@ -2,6 +2,8 @@ const std = @import("std");
const Context = @import("context.zig");
const Storage = @import("../storage/root.zig");
+const config = @import("config");
+
const Access = @import("access.zig").Access;
const log = std.log.scoped(.handler_info);
@@ -71,22 +73,24 @@ pub fn handle(
.fingerprint = get_fingerprint(cookie),
};
- const allowed = switch (self.access) {
- .everyone => true,
- .users => storage.sessions.get(storage, context.fingerprint) != null,
- .admins => admin: {
- if (storage.sessions.get(storage, context.fingerprint)) |session| {
- break :admin session.info.is_admin;
- }
- break :admin false;
- },
- };
+ if (!comptime config.disable_auth) {
+ const allowed = switch (self.access) {
+ .everyone => true,
+ .users => storage.sessions.get(storage, context.fingerprint) != null,
+ .admins => admin: {
+ if (storage.sessions.get(storage, context.fingerprint)) |session| {
+ break :admin session.info.is_admin;
+ }
+ break :admin false;
+ },
+ };
- if (!allowed) {
- return request.respond(
- "{ \"error\": \"Forbidden\" }",
- .{ .status = .forbidden }
- );
+ if (!allowed) {
+ return request.respond(
+ "{ \"error\": \"Forbidden\" }",
+ .{ .status = .forbidden }
+ );
+ }
}
const response = handler(&context) catch |err| {