角色基础 Curd 操作 NodeJs API(用户、管理员、超级管理员)

时间:2021-06-03 03:07:23

标签: node.js express jwt authorization

我想创建角色基础 API(用户、管理员、超级管理员),其中超级管理员可以访问所有路由,但管理员只能访问超级管理员授予访问权限的模型。

这是创建的模型:

 name: {
        type: String,
        required: [true, 'Please enter product name'],
        trim: true,
        maxLength: [100, 'Product name cannot exceed 100 characters']
    },
    price: {
        type: Number,
        required: [true, 'Please enter product price'],
        maxLength: [10, 'Product name cannot exceed 5 characters'],
        default: 0.0
    },
    description: {
        type: String,
        required: [true, 'Please enter product description'],
    },
productSeller:{
type:string,
required
}

superadmin 在哪里可以对所有产品进行 CRUD 操作,而 admin 只能根据卖家名称进行 crud 操作(即从 superadmain 访问)?

0 个答案:

没有答案
相关问题