feat: Add role-based email limit exemption for emperors

This commit is contained in:
beilunyang
2025-02-27 23:59:36 +08:00
parent 59671091b6
commit f86d944c25
4 changed files with 58 additions and 15 deletions
+9
View File
@@ -52,6 +52,15 @@ export async function assignRoleToUser(db: Db, userId: string, roleId: string) {
})
}
export async function getUserRole(userId: string) {
const db = createDb()
const userRoleRecords = await db.query.userRoles.findMany({
where: eq(userRoles.userId, userId),
with: { role: true },
})
return userRoleRecords[0].role.name
}
export async function checkPermission(permission: Permission) {
const session = await auth()
if (!session?.user?.id) return false