Files
website-enchun-mgr/apps/backend/src/access/adminOrEditor.ts
pkupuk d0e8c3bcff Add role-based access control with admin/editor roles
Create adminOnly and adminOrEditor access functions. Add role field
to Users collection (admin/editor, default: editor). Update access control
across all collections and globals to enforce role-based permissions.
2026-01-31 13:03:16 +08:00

15 lines
378 B
TypeScript

import type { Access } from 'payload'
/**
* 允許 Admin 或 Editor 角色訪問
*
* 用例:
* - Posts/Pages collection (內容管理)
* - Categories collection (內容分類)
* - Portfolio collection (作品管理)
*/
export const adminOrEditor: Access = ({ req: { user } }) => {
if (!user) return false
return user?.role === 'admin' || user?.role === 'editor'
}