1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

fix: OIDC finalization and refactoring

This commit is contained in:
Maksim Eltyshev 2023-10-17 19:18:19 +02:00
parent c21e9cb60a
commit b9716c6e3a
70 changed files with 753 additions and 427 deletions

View file

@ -1,4 +1,7 @@
const Errors = {
NOT_ENOUGH_RIGHTS: {
notEnoughRights: 'Not enough rights',
},
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
@ -14,6 +17,9 @@ module.exports = {
},
exits: {
notEnoughRights: {
responseType: 'forbidden',
},
userNotFound: {
responseType: 'notFound',
},
@ -27,7 +33,7 @@ module.exports = {
}
if (user.email === sails.config.custom.defaultAdminEmail) {
throw Errors.USER_NOT_FOUND; // Forbidden
throw Errors.NOT_ENOUGH_RIGHTS;
}
user = await sails.helpers.users.deleteOne.with({

View file

@ -1,6 +1,9 @@
const bcrypt = require('bcrypt');
const Errors = {
NOT_ENOUGH_RIGHTS: {
notEnoughRights: 'Not enough rights',
},
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
@ -31,6 +34,9 @@ module.exports = {
},
exits: {
notEnoughRights: {
responseType: 'forbidden',
},
userNotFound: {
responseType: 'notFound',
},
@ -59,8 +65,8 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
if (user.email === sails.config.custom.defaultAdminEmail) {
throw Errors.USER_NOT_FOUND; // Forbidden
if (user.email === sails.config.custom.defaultAdminEmail || user.isSso) {
throw Errors.NOT_ENOUGH_RIGHTS;
}
if (

View file

@ -4,6 +4,9 @@ const zxcvbn = require('zxcvbn');
const { getRemoteAddress } = require('../../../utils/remoteAddress');
const Errors = {
NOT_ENOUGH_RIGHTS: {
notEnoughRights: 'Not enough rights',
},
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
@ -33,6 +36,9 @@ module.exports = {
},
exits: {
notEnoughRights: {
responseType: 'forbidden',
},
userNotFound: {
responseType: 'notFound',
},
@ -58,8 +64,8 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
if (user.email === sails.config.custom.defaultAdminEmail) {
throw Errors.USER_NOT_FOUND; // Forbidden
if (user.email === sails.config.custom.defaultAdminEmail || user.isSso) {
throw Errors.NOT_ENOUGH_RIGHTS;
}
if (

View file

@ -1,6 +1,9 @@
const bcrypt = require('bcrypt');
const Errors = {
NOT_ENOUGH_RIGHTS: {
notEnoughRights: 'Not enough rights',
},
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
@ -33,6 +36,9 @@ module.exports = {
},
exits: {
notEnoughRights: {
responseType: 'forbidden',
},
userNotFound: {
responseType: 'notFound',
},
@ -61,8 +67,8 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
if (user.email === sails.config.custom.defaultAdminEmail) {
throw Errors.USER_NOT_FOUND; // Forbidden
if (user.email === sails.config.custom.defaultAdminEmail || user.isSso) {
throw Errors.NOT_ENOUGH_RIGHTS;
}
if (

View file

@ -72,6 +72,8 @@ module.exports = {
delete inputs.isAdmin;
delete inputs.name;
/* eslint-enable no-param-reassign */
} else if (user.isSso) {
delete inputs.name; // eslint-disable-line no-param-reassign
}
const values = {