17 lines
435 B
TypeScript
17 lines
435 B
TypeScript
import { RoleModel } from "@/models/role.model";
|
|
|
|
import type { Role } from "@/types/models/role.type";
|
|
import type { Account } from "@/types/models/account.type";
|
|
|
|
export class AccountService {
|
|
public static async determineAccountRole(account: Account): Promise<Role> {
|
|
const role = await RoleModel.findOne({ name: account.role }).lean();
|
|
|
|
if (!role) {
|
|
throw new Error("role not found");
|
|
}
|
|
|
|
return role;
|
|
}
|
|
}
|