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,
|
alloc: std.mem.Allocator,
|
||||||
ctx: ApiContext,
|
ctx: ApiContext,
|
||||||
svcs: anytype,
|
svcs: anytype,
|
||||||
|
username: []const u8,
|
||||||
|
password: []const u8,
|
||||||
opt: RegistrationOptions,
|
opt: RegistrationOptions,
|
||||||
) !Uuid {
|
) !Uuid {
|
||||||
const tx = try svcs.beginTx();
|
const tx = try svcs.beginTx();
|
||||||
|
@ -44,8 +46,8 @@ pub fn register(
|
||||||
alloc,
|
alloc,
|
||||||
tx,
|
tx,
|
||||||
.{
|
.{
|
||||||
.username = opt.username,
|
.username = username,
|
||||||
.password = opt.password,
|
.password = password,
|
||||||
.community_id = ctx.community.id,
|
.community_id = ctx.community.id,
|
||||||
.invite_id = if (maybe_invite) |inv| @as(?Uuid, inv.id) else null,
|
.invite_id = if (maybe_invite) |inv| @as(?Uuid, inv.id) else null,
|
||||||
.email = opt.email,
|
.email = opt.email,
|
||||||
|
|
|
@ -15,8 +15,6 @@ fn QueryResult(comptime R: type, comptime A: type) type {
|
||||||
|
|
||||||
pub const auth = struct {
|
pub const auth = struct {
|
||||||
pub const RegistrationOptions = struct {
|
pub const RegistrationOptions = struct {
|
||||||
username: []const u8,
|
|
||||||
password: []const u8,
|
|
||||||
invite_code: ?[]const u8 = null,
|
invite_code: ?[]const u8 = null,
|
||||||
email: ?[]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 {
|
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
|
||||||
const options = .{
|
const options = .{
|
||||||
.username = req.body.username,
|
|
||||||
.password = req.body.password,
|
|
||||||
.invite_code = req.body.invite_code,
|
.invite_code = req.body.invite_code,
|
||||||
.email = req.body.email,
|
.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", {}),
|
error.UsernameTaken => return res.err(.unprocessable_entity, "Username Unavailable", {}),
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue