From ecd844ddd13f1a1fa5852b3f8b2be2a79695a3b6 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sun, 1 Jan 2023 16:14:04 -0800 Subject: [PATCH] Move login to methods/auth.zig --- src/api/lib.zig | 10 ---------- src/api/methods/auth.zig | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/api/lib.zig b/src/api/lib.zig index 774b1aa..e6c0006 100644 --- a/src/api/lib.zig +++ b/src/api/lib.zig @@ -345,16 +345,6 @@ fn ApiConn(comptime DbConn: type, comptime models: anytype) type { return self.context.userId() != null and self.context.community.kind == .admin; } - pub fn login(self: *Self, username: []const u8, password: []const u8) !Token { - return models.auth.login( - self.db, - username, - self.context.community.id, - password, - self.allocator, - ); - } - pub const AuthorizationInfo = struct { id: Uuid, username: []const u8, diff --git a/src/api/methods/auth.zig b/src/api/methods/auth.zig index 3f994d8..217e990 100644 --- a/src/api/methods/auth.zig +++ b/src/api/methods/auth.zig @@ -7,6 +7,7 @@ const DateTime = util.DateTime; const RegistrationOptions = @import("../lib.zig").RegistrationOptions; const UserResponse = @import("../lib.zig").UserResponse; const Invite = @import("../lib.zig").Invite; +pub const Token = types.Token; pub fn methods(comptime models: type) type { return struct { @@ -61,6 +62,16 @@ pub fn methods(comptime models: type) type { try tx.commitOrRelease(); return user; } + + pub fn login(self: anytype, username: []const u8, password: []const u8) !Token { + return models.auth.login( + self.db, + username, + self.context.community.id, + password, + self.allocator, + ); + } }; }