mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
* https://github.com/jambonz/jambonz-api-server/issues/371 Implemented view_only permission feature * calling prepare-permissions in create-test-db.js * check if there is only 1 permission and if it is VIEW_ONLY then consider user as read-only user * setting is_view_only flag for view user by userid
46 lines
793 B
JavaScript
46 lines
793 B
JavaScript
const Model = require('./model');
|
|
const {promisePool} = require('../db');
|
|
const sqlAll = `
|
|
SELECT * from permissions
|
|
`;
|
|
const sqlByName = `
|
|
SELECT * from permissions where name = ?
|
|
`;
|
|
|
|
class Permissions extends Model {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
static async retrieveAll() {
|
|
const [rows] = await promisePool.query(sqlAll);
|
|
return rows;
|
|
}
|
|
|
|
static async retrieveByName(name) {
|
|
const [rows] = await promisePool.query(sqlByName, [name]);
|
|
return rows;
|
|
}
|
|
}
|
|
|
|
Permissions.table = 'permissions';
|
|
Permissions.fields = [
|
|
{
|
|
name: 'permission_sid',
|
|
type: 'string',
|
|
primaryKey: true
|
|
},
|
|
{
|
|
name: 'name',
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
];
|
|
|
|
module.exports = Permissions;
|