Move login to methods/auth.zig
This commit is contained in:
parent
ec4e99c41e
commit
ecd844ddd1
2 changed files with 11 additions and 10 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue