@dax-crafta/auth
Version:
A powerful, flexible, and secure authentication plugin for the Crafta framework. Supports JWT, social login, 2FA, RBAC, audit logging, and enterprise-grade security features.
33 lines (30 loc) • 631 B
JavaScript
const mongoose = require('mongoose');
const roleSchema = new mongoose.Schema({
name: {
type: String,
required: true,
unique: true
},
permissions: [{
resource: String,
actions: [{
type: String,
enum: ['create', 'read', 'update', 'delete', 'manage']
}]
}],
description: String,
isSystem: {
type: Boolean,
default: false
},
createdAt: {
type: Date,
default: Date.now
},
updatedAt: Date
});
roleSchema.pre('save', function(next) {
this.updatedAt = new Date();
next();
});
module.exports = mongoose.model('Role', roleSchema);