Fix compilation errors
This commit is contained in:
parent
a1a93a7466
commit
93f2c6d674
3 changed files with 5 additions and 7 deletions
|
@ -17,6 +17,8 @@ pub fn register(
|
|||
alloc: std.mem.Allocator,
|
||||
ctx: ApiContext,
|
||||
svcs: anytype,
|
||||
username: []const u8,
|
||||
password: []const u8,
|
||||
opt: RegistrationOptions,
|
||||
) !Uuid {
|
||||
const tx = try svcs.beginTx();
|
||||
|
@ -44,8 +46,8 @@ pub fn register(
|
|||
alloc,
|
||||
tx,
|
||||
.{
|
||||
.username = opt.username,
|
||||
.password = opt.password,
|
||||
.username = username,
|
||||
.password = password,
|
||||
.community_id = ctx.community.id,
|
||||
.invite_id = if (maybe_invite) |inv| @as(?Uuid, inv.id) else null,
|
||||
.email = opt.email,
|
||||
|
|
|
@ -15,8 +15,6 @@ fn QueryResult(comptime R: type, comptime A: type) type {
|
|||
|
||||
pub const auth = struct {
|
||||
pub const RegistrationOptions = struct {
|
||||
username: []const u8,
|
||||
password: []const u8,
|
||||
invite_code: ?[]const u8 = null,
|
||||
email: ?[]const u8 = null,
|
||||
};
|
||||
|
|
|
@ -14,12 +14,10 @@ pub const create = struct {
|
|||
|
||||
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
|
||||
const options = .{
|
||||
.username = req.body.username,
|
||||
.password = req.body.password,
|
||||
.invite_code = req.body.invite_code,
|
||||
.email = req.body.email,
|
||||
};
|
||||
const user = srv.register(options) catch |err| switch (err) {
|
||||
const user = srv.register(req.body.username, req.body.password, options) catch |err| switch (err) {
|
||||
error.UsernameTaken => return res.err(.unprocessable_entity, "Username Unavailable", {}),
|
||||
else => return err,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue