added tons of features

This commit is contained in:
2025-02-05 08:01:14 +02:00
parent 4ae0d8c545
commit 8138da6b1d
195 changed files with 12619 additions and 415 deletions

View File

@@ -0,0 +1,30 @@
'use server'
import {auth} from '@/auth'
import {
Access,
AllRolesPermissions,
PERMISSIONS,
type Permission,
type SingedInSession
} from '@/lib/permission'
export type CanAccessResponse = {can: boolean; session: SingedInSession | null}
export type CanResponse = boolean | CanAccessResponse
const can = async (permission: Permission): Promise<CanResponse> => {
const session: SingedInSession = (await auth()) as SingedInSession
if (!session) return false
const able =
PERMISSIONS[session.user.role as keyof AllRolesPermissions].includes(
permission
)
return !Object.values(Access).includes(permission as Access)
? able
: {can: able, session}
}
export default can