aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/auth/create-user.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/api/auth/create-user.zig')
-rw-r--r--src/routes/api/auth/create-user.zig29
1 files changed, 29 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();
+}