diff options
Diffstat (limited to 'src/routes/api/auth')
| -rw-r--r-- | src/routes/api/auth/first-login.zig | 15 | ||||
| -rw-r--r-- | src/routes/api/auth/login.zig | 34 | ||||
| -rw-r--r-- | src/routes/api/auth/root.zig | 4 |
3 files changed, 0 insertions, 53 deletions
diff --git a/src/routes/api/auth/first-login.zig b/src/routes/api/auth/first-login.zig deleted file mode 100644 index 523fdf4..0000000 --- a/src/routes/api/auth/first-login.zig +++ /dev/null @@ -1,15 +0,0 @@ -const std = @import("std"); - -const memora = @import("memora"); -const Context = memora.Context; - -pub const access = .everyone; - -const Result = struct { - is_first: bool, -}; - -pub fn post(ctx: *Context) anyerror!Result { - _ = ctx; - return .{ .is_first = false }; -} diff --git a/src/routes/api/auth/login.zig b/src/routes/api/auth/login.zig deleted file mode 100644 index 8a33082..0000000 --- a/src/routes/api/auth/login.zig +++ /dev/null @@ -1,34 +0,0 @@ -const std = @import("std"); - -const memora = @import("memora"); -const Context = memora.Context; -const Storage = memora.Storage; - -const Body = struct { - user: []const u8, - password: []const u8, -}; - -const Result = struct { - success: bool, -}; - -pub const access = .everyone; - -pub fn post(ctx: *Context, body: Body) anyerror!Result { - var user = Storage.User.open(ctx.storage, body.user) catch return .{ - .success = false - }; - defer user.deinit(); - - const result = Result { - .success = user.check_password(body.password) - }; - - if (result.success) { - const session = try ctx.storage.sessions.add(ctx.storage, user.info); - ctx.response.headers.fingerprint = session.fingerprint; - } - - return result; -} diff --git a/src/routes/api/auth/root.zig b/src/routes/api/auth/root.zig deleted file mode 100644 index 5f45891..0000000 --- a/src/routes/api/auth/root.zig +++ /dev/null @@ -1,4 +0,0 @@ -const HandlerInfo = @import("../../handler-info.zig"); - -pub const login: HandlerInfo = .from_type(@import("login.zig")); -pub const @"first-login": HandlerInfo = .from_type(@import("first-login.zig")); |