diff options
Diffstat (limited to 'src/routes/api/auth')
| -rw-r--r-- | src/routes/api/auth/create-user.zig | 29 | ||||
| -rw-r--r-- | src/routes/api/auth/root.zig | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/routes/api/auth/create-user.zig b/src/routes/api/auth/create-user.zig new file mode 100644 index 0000000..6bd9a82 --- /dev/null +++ b/src/routes/api/auth/create-user.zig @@ -0,0 +1,29 @@ +const std = @import("std"); + +const memora = @import("memora"); +const Context = memora.Context; +const Storage = memora.Storage; + +pub const access = .admins; + +pub const Body = struct { + name: []const u8, + full_name: []const u8, + birthday: []const u8, + password: []const u8, +}; + +pub fn post(ctx: *Context, body: Body) anyerror!void { + var user = try Storage.User.new( + ctx.storage, + body.name, + body.full_name, + body.birthday, + body.password, + false, + ctx.storage.allocator, + ); + defer user.deinit(); + + try user.sync(); +} diff --git a/src/routes/api/auth/root.zig b/src/routes/api/auth/root.zig index 5f45891..fa93c92 100644 --- a/src/routes/api/auth/root.zig +++ b/src/routes/api/auth/root.zig @@ -2,3 +2,4 @@ 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")); +pub const @"create-user": HandlerInfo = .from_type(@import("create-user.zig")); |