Move login to methods/auth.zig
This commit is contained in:
parent
ec4e99c41e
commit
ecd844ddd1
|
@ -345,16 +345,6 @@ fn ApiConn(comptime DbConn: type, comptime models: anytype) type {
|
||||||
return self.context.userId() != null and self.context.community.kind == .admin;
|
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 {
|
pub const AuthorizationInfo = struct {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
username: []const u8,
|
username: []const u8,
|
||||||
|
|
|
@ -7,6 +7,7 @@ const DateTime = util.DateTime;
|
||||||
const RegistrationOptions = @import("../lib.zig").RegistrationOptions;
|
const RegistrationOptions = @import("../lib.zig").RegistrationOptions;
|
||||||
const UserResponse = @import("../lib.zig").UserResponse;
|
const UserResponse = @import("../lib.zig").UserResponse;
|
||||||
const Invite = @import("../lib.zig").Invite;
|
const Invite = @import("../lib.zig").Invite;
|
||||||
|
pub const Token = types.Token;
|
||||||
|
|
||||||
pub fn methods(comptime models: type) type {
|
pub fn methods(comptime models: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -61,6 +62,16 @@ pub fn methods(comptime models: type) type {
|
||||||
try tx.commitOrRelease();
|
try tx.commitOrRelease();
|
||||||
return user;
|
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 New Issue