mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
fix: Disable role change when OIDC roles are not ignored
This commit is contained in:
parent
e41a434fc8
commit
d951ba59dd
9 changed files with 23 additions and 20 deletions
|
@ -155,7 +155,7 @@ const ActionsStep = React.memo(
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!user.isLockedAdmin && (
|
{!user.isDeletionLocked && (
|
||||||
<Menu.Item className={styles.menuItem} onClick={handleDeleteClick}>
|
<Menu.Item className={styles.menuItem} onClick={handleDeleteClick}>
|
||||||
{t('action.deleteUser', {
|
{t('action.deleteUser', {
|
||||||
context: 'title',
|
context: 'title',
|
||||||
|
|
|
@ -18,7 +18,8 @@ const Item = React.memo(
|
||||||
phone,
|
phone,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isLocked,
|
isLocked,
|
||||||
isLockedAdmin,
|
isRoleLocked,
|
||||||
|
isDeletionLocked,
|
||||||
emailUpdateForm,
|
emailUpdateForm,
|
||||||
passwordUpdateForm,
|
passwordUpdateForm,
|
||||||
usernameUpdateForm,
|
usernameUpdateForm,
|
||||||
|
@ -48,7 +49,7 @@ const Item = React.memo(
|
||||||
<Table.Cell>{username || '-'}</Table.Cell>
|
<Table.Cell>{username || '-'}</Table.Cell>
|
||||||
<Table.Cell>{email}</Table.Cell>
|
<Table.Cell>{email}</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<Radio toggle checked={isAdmin} disabled={isLockedAdmin} onChange={handleIsAdminChange} />
|
<Radio toggle checked={isAdmin} disabled={isRoleLocked} onChange={handleIsAdminChange} />
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell textAlign="right">
|
<Table.Cell textAlign="right">
|
||||||
<ActionsPopup
|
<ActionsPopup
|
||||||
|
@ -60,7 +61,7 @@ const Item = React.memo(
|
||||||
phone,
|
phone,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isLocked,
|
isLocked,
|
||||||
isLockedAdmin,
|
isDeletionLocked,
|
||||||
emailUpdateForm,
|
emailUpdateForm,
|
||||||
passwordUpdateForm,
|
passwordUpdateForm,
|
||||||
usernameUpdateForm,
|
usernameUpdateForm,
|
||||||
|
@ -93,7 +94,8 @@ Item.propTypes = {
|
||||||
phone: PropTypes.string,
|
phone: PropTypes.string,
|
||||||
isAdmin: PropTypes.bool.isRequired,
|
isAdmin: PropTypes.bool.isRequired,
|
||||||
isLocked: PropTypes.bool.isRequired,
|
isLocked: PropTypes.bool.isRequired,
|
||||||
isLockedAdmin: PropTypes.bool.isRequired,
|
isRoleLocked: PropTypes.bool.isRequired,
|
||||||
|
isDeletionLocked: PropTypes.bool.isRequired,
|
||||||
/* eslint-disable react/forbid-prop-types */
|
/* eslint-disable react/forbid-prop-types */
|
||||||
emailUpdateForm: PropTypes.object.isRequired,
|
emailUpdateForm: PropTypes.object.isRequired,
|
||||||
passwordUpdateForm: PropTypes.object.isRequired,
|
passwordUpdateForm: PropTypes.object.isRequired,
|
||||||
|
|
|
@ -111,7 +111,8 @@ const UsersModal = React.memo(
|
||||||
phone={item.phone}
|
phone={item.phone}
|
||||||
isAdmin={item.isAdmin}
|
isAdmin={item.isAdmin}
|
||||||
isLocked={item.isLocked}
|
isLocked={item.isLocked}
|
||||||
isLockedAdmin={item.isLockedAdmin}
|
isRoleLocked={item.isRoleLocked}
|
||||||
|
isDeletionLocked={item.isDeletionLocked}
|
||||||
emailUpdateForm={item.emailUpdateForm}
|
emailUpdateForm={item.emailUpdateForm}
|
||||||
passwordUpdateForm={item.passwordUpdateForm}
|
passwordUpdateForm={item.passwordUpdateForm}
|
||||||
usernameUpdateForm={item.usernameUpdateForm}
|
usernameUpdateForm={item.usernameUpdateForm}
|
||||||
|
|
|
@ -45,7 +45,8 @@ export default class extends BaseModel {
|
||||||
subscribeToOwnCards: attr(),
|
subscribeToOwnCards: attr(),
|
||||||
isAdmin: attr(),
|
isAdmin: attr(),
|
||||||
isLocked: attr(),
|
isLocked: attr(),
|
||||||
isLockedAdmin: attr(),
|
isRoleLocked: attr(),
|
||||||
|
isDeletionLocked: attr(),
|
||||||
deletedAt: attr(),
|
deletedAt: attr(),
|
||||||
createdAt: attr({
|
createdAt: attr({
|
||||||
getDefault: () => new Date(),
|
getDefault: () => new Date(),
|
||||||
|
|
|
@ -73,6 +73,10 @@ module.exports = {
|
||||||
delete inputs.name;
|
delete inputs.name;
|
||||||
/* eslint-enable no-param-reassign */
|
/* eslint-enable no-param-reassign */
|
||||||
} else if (user.isSso) {
|
} else if (user.isSso) {
|
||||||
|
if (!sails.config.custom.oidcIgnoreRoles) {
|
||||||
|
delete inputs.isAdmin; // eslint-disable-line no-param-reassign
|
||||||
|
}
|
||||||
|
|
||||||
delete inputs.name; // eslint-disable-line no-param-reassign
|
delete inputs.name; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,9 @@ module.exports = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateFieldKeys = ['email', 'isAdmin', 'isSso', 'name', 'username'];
|
const updateFieldKeys = ['email', 'isSso', 'name', 'username'];
|
||||||
|
if (!sails.config.custom.oidcIgnoreRoles) {
|
||||||
if (sails.config.custom.oidcIgnoreRoles) {
|
updateFieldKeys.push('isAdmin');
|
||||||
// Remove isAdmin from updateFieldKeys
|
|
||||||
updateFieldKeys.splice(updateFieldKeys.indexOf('isAdmin'), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateValues = {};
|
const updateValues = {};
|
||||||
|
|
|
@ -110,12 +110,13 @@ module.exports = {
|
||||||
tableName: 'user_account',
|
tableName: 'user_account',
|
||||||
|
|
||||||
customToJSON() {
|
customToJSON() {
|
||||||
const isLockedAdmin = this.email === sails.config.custom.defaultAdminEmail;
|
const isDefaultAdmin = this.email === sails.config.custom.defaultAdminEmail;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
..._.omit(this, ['password', 'isSso', 'avatar', 'passwordChangedAt']),
|
..._.omit(this, ['password', 'isSso', 'avatar', 'passwordChangedAt']),
|
||||||
isLockedAdmin,
|
isLocked: this.isSso || isDefaultAdmin,
|
||||||
isLocked: this.isSso || isLockedAdmin,
|
isRoleLocked: (this.isSso && !sails.config.custom.oidcIgnoreRoles) || isDefaultAdmin,
|
||||||
|
isDeletionLocked: isDefaultAdmin,
|
||||||
avatarUrl:
|
avatarUrl:
|
||||||
this.avatar &&
|
this.avatar &&
|
||||||
`${sails.config.custom.userAvatarsUrl}/${this.avatar.dirname}/square-100.${this.avatar.extension}`,
|
`${sails.config.custom.userAvatarsUrl}/${this.avatar.dirname}/square-100.${this.avatar.extension}`,
|
||||||
|
|
|
@ -39,7 +39,7 @@ module.exports.custom = {
|
||||||
oidcScopes: process.env.OIDC_SCOPES || 'openid email profile',
|
oidcScopes: process.env.OIDC_SCOPES || 'openid email profile',
|
||||||
oidcAdminRoles: process.env.OIDC_ADMIN_ROLES ? process.env.OIDC_ADMIN_ROLES.split(',') : [],
|
oidcAdminRoles: process.env.OIDC_ADMIN_ROLES ? process.env.OIDC_ADMIN_ROLES.split(',') : [],
|
||||||
oidcRolesAttribute: process.env.OIDC_ROLES_ATTRIBUTE || 'groups',
|
oidcRolesAttribute: process.env.OIDC_ROLES_ATTRIBUTE || 'groups',
|
||||||
oidcIgnoreRoles : process.env.OIDC_IGNORE_ROLES || false,
|
oidcIgnoreRoles: process.env.OIDC_IGNORE_ROLES === 'true',
|
||||||
|
|
||||||
// TODO: move client base url to environment variable?
|
// TODO: move client base url to environment variable?
|
||||||
oidcRedirectUri: `${
|
oidcRedirectUri: `${
|
||||||
|
|
|
@ -34,10 +34,6 @@ exports.seed = async (knex) => {
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (Object.keys(data).length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await knex('user_account').update(data).where('email', process.env.DEFAULT_ADMIN_EMAIL);
|
await knex('user_account').update(data).where('email', process.env.DEFAULT_ADMIN_EMAIL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue