pequeño refactor CR JOAN
This commit is contained in:
parent
1af698acc3
commit
4ebca3f3cb
|
@ -7,7 +7,7 @@ module.exports = Self => {
|
|||
* @param {Integer} stateId The user id
|
||||
* @return {Boolean} %true if user has the role, %false otherwise
|
||||
*/
|
||||
Self.isAlertLevel0 = async function(stateId) {
|
||||
Self.isAlertLevelZero = async function(stateId) {
|
||||
let result = await Self.rawSql(
|
||||
`SELECT alertLevel
|
||||
FROM vn.state
|
||||
|
|
|
@ -10,10 +10,10 @@ module.exports = function(Self) {
|
|||
|
||||
let isEmployee = await models.Account.hasRole(userId, 'employee');
|
||||
let isProduction = await models.Account.hasRole(userId, 'production');
|
||||
let isAlertLevel0 = await models.State.isAlertLevel0(ctx.instance.stateFk);
|
||||
let isAlertLevelZero = await models.State.isAlertLevelZero(ctx.instance.stateFk);
|
||||
let ticketAlertLevel = await models.TicketState.findOne({where: {id: ctx.instance.ticketFk}, fields: ["alertLevel"]});
|
||||
|
||||
if ((!isProduction && !isAlertLevel0) || !isEmployee || (isEmployee && ticketAlertLevel != 0 && !isProduction))
|
||||
if ((!isProduction && !isAlertLevelZero) || !isEmployee || (isEmployee && ticketAlertLevel != 0 && !isProduction))
|
||||
throw new Error("You don't have enough privileges to do that");
|
||||
|
||||
let user = await models.Worker.findOne({where: {userFk: userId}});
|
||||
|
|
Loading…
Reference in New Issue