summaryrefslogtreecommitdiff
path: root/backend/src/API/AuthenticationAPI.zig
diff options
context:
space:
mode:
Diffstat (limited to 'backend/src/API/AuthenticationAPI.zig')
-rw-r--r--backend/src/API/AuthenticationAPI.zig8
1 files changed, 3 insertions, 5 deletions
diff --git a/backend/src/API/AuthenticationAPI.zig b/backend/src/API/AuthenticationAPI.zig
index a792e33..9b45ff4 100644
--- a/backend/src/API/AuthenticationAPI.zig
+++ b/backend/src/API/AuthenticationAPI.zig
@@ -6,12 +6,12 @@ const errDesc = @import("ErrorDescription.zig");
const Handler = @import("../Handler.zig");
const Tokens = @import("../Authentication/Tokens.zig");
-pub fn RegisterEndpoints(router: *httpz.Router(*Handler.Handler,*const fn (*Handler.Handler, *httpz.request.Request, *httpz.response.Response) anyerror!void)) void {
+pub fn RegisterEndpoints(router: *httpz.Router(*Handler.Handler,*const fn (*Handler.RequestData, *httpz.request.Request, *httpz.response.Response) anyerror!void)) void {
router.post("/auth/register", register, .{});
router.post("/auth/login", login, .{});
}
-fn register(_: *Handler.Handler, req: *httpz.Request, res: *httpz.Response) !void {
+fn register(_: *Handler.RequestData, req: *httpz.Request, res: *httpz.Response) !void {
var body = try req.json(model.RequestBody) orelse {
res.setStatus(.bad_request);
return;
@@ -31,7 +31,7 @@ fn register(_: *Handler.Handler, req: *httpz.Request, res: *httpz.Response) !voi
res.setStatus(.created);
}
-fn login(_: *Handler.Handler, req: *httpz.Request, res: *httpz.Response) !void {
+fn login(_: *Handler.RequestData, req: *httpz.Request, res: *httpz.Response) !void {
const body = try req.json(model.RequestBody) orelse {
res.setStatus(.bad_request);
return;
@@ -53,6 +53,4 @@ fn login(_: *Handler.Handler, req: *httpz.Request, res: *httpz.Response) !void {
const token = try Tokens.GenerateNewSession(res.arena, user);
try res.json(.{ .Token = token } , .{});
-
- // TODO: add token here
}