mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
import { v4 as uuid } from 'uuid'
|
|
import { groupsTable } from '../db/schema.mjs'
|
|
|
|
/**
|
|
* Groups model
|
|
*/
|
|
class Groups {
|
|
async init (ids) {
|
|
WIKI.logger.info('Inserting default groups...')
|
|
|
|
await WIKI.db.insert(groupsTable).values([
|
|
{
|
|
id: ids.groupAdminId,
|
|
name: 'Administrators',
|
|
permissions: ['manage:system'],
|
|
rules: [],
|
|
isSystem: true
|
|
},
|
|
{
|
|
id: ids.groupUserId,
|
|
name: 'Users',
|
|
permissions: ['read:pages', 'read:assets', 'read:comments'],
|
|
rules: [
|
|
{
|
|
id: uuid(),
|
|
name: 'Default Rule',
|
|
roles: ['read:pages', 'read:assets', 'read:comments'],
|
|
match: 'START',
|
|
mode: 'ALLOW',
|
|
path: '',
|
|
locales: [],
|
|
sites: []
|
|
}
|
|
],
|
|
isSystem: true
|
|
},
|
|
{
|
|
id: ids.groupGuestId,
|
|
name: 'Guests',
|
|
permissions: ['read:pages', 'read:assets', 'read:comments'],
|
|
rules: [
|
|
{
|
|
id: uuid(),
|
|
name: 'Default Rule',
|
|
roles: ['read:pages', 'read:assets', 'read:comments'],
|
|
match: 'START',
|
|
mode: 'DENY',
|
|
path: '',
|
|
locales: [],
|
|
sites: []
|
|
}
|
|
],
|
|
isSystem: true
|
|
}
|
|
])
|
|
}
|
|
}
|
|
|
|
export const groups = new Groups()
|