summaryrefslogtreecommitdiff
path: root/backend/src/API
diff options
context:
space:
mode:
authorphyscik <mynameisgennadiy@vk.com>2026-04-20 21:52:20 +0500
committerphyscik <mynameisgennadiy@vk.com>2026-04-20 21:52:20 +0500
commitd46bf56209ca250fc4108af46375359652ba7fd8 (patch)
treee58eabb502abfe839ac839c39d2c92896d130b43 /backend/src/API
parent6898919979c914be4c4650158fe0451a21349bb5 (diff)
Cleanup
Diffstat (limited to 'backend/src/API')
-rw-r--r--backend/src/API/AuthenticationAPI.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/src/API/AuthenticationAPI.zig b/backend/src/API/AuthenticationAPI.zig
index 9b45ff4..80988aa 100644
--- a/backend/src/API/AuthenticationAPI.zig
+++ b/backend/src/API/AuthenticationAPI.zig
@@ -7,10 +7,22 @@ const Handler = @import("../Handler.zig");
const Tokens = @import("../Authentication/Tokens.zig");
pub fn RegisterEndpoints(router: *httpz.Router(*Handler.Handler,*const fn (*Handler.RequestData, *httpz.request.Request, *httpz.response.Response) anyerror!void)) void {
+ router.get("/auth", getUser, .{});
router.post("/auth/register", register, .{});
router.post("/auth/login", login, .{});
}
+fn getUser(data: *Handler.RequestData, _: *httpz.Request, res: *httpz.Response) !void {
+ if (data.User == null) {
+ try res.json(.{.status = "Unauthnticated"}, .{});
+ return;
+ }
+ try res.json(.{
+ .Username = data.User.?.Username,
+ .Role = data.User.?.Role,
+ }, .{});
+}
+
fn register(_: *Handler.RequestData, req: *httpz.Request, res: *httpz.Response) !void {
var body = try req.json(model.RequestBody) orelse {
res.setStatus(.bad_request);