add client/admin pages, show info and created admin api and server actions
This commit is contained in:
14
actions/admin.ts
Normal file
14
actions/admin.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
'use server'
|
||||
|
||||
import { currentRole } from '@/lib/auth'
|
||||
import { UserRole } from '@prisma/client'
|
||||
|
||||
export const admin = async () => {
|
||||
const role = await currentRole()
|
||||
|
||||
if (role === UserRole.ADMIN) {
|
||||
return { success: `Allowed Server Action for ${UserRole.ADMIN}` }
|
||||
}
|
||||
|
||||
return { error: `Forbidden Server Action for ${UserRole.ADMIN}` }
|
||||
}
|
||||
Reference in New Issue
Block a user