aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/auth/login.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/api/auth/login.zig')
-rw-r--r--src/routes/api/auth/login.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/routes/api/auth/login.zig b/src/routes/api/auth/login.zig
new file mode 100644
index 0000000..c3f2bef
--- /dev/null
+++ b/src/routes/api/auth/login.zig
@@ -0,0 +1,25 @@
+const std = @import("std");
+
+const Context = @import("../../context.zig");
+const Storage = @import("../../../storage/root.zig");
+
+pub const needs_auth = false;
+pub const method = .POST;
+
+const Body = struct {
+ user: []const u8,
+ password: []const u8,
+};
+
+const Result = struct {
+ success: bool,
+};
+
+pub fn handler(ctx: *Context, body: Body) anyerror!Result {
+ var user = Storage.User.open(ctx.storage, body.user, ctx.allocator) catch return .{
+ .success = false
+ };
+ defer user.deinit();
+
+ return .{ .success = user.check_password(body.password) };
+}