Merge pull request #5370 from mikiher/fix/root-user-delete-protection

Prevent admin users from deleting the root account
This commit is contained in:
advplyr
2026-07-20 18:35:32 -04:00
committed by GitHub
3 changed files with 40 additions and 6 deletions
+8 -1
View File
@@ -530,7 +530,14 @@ class User extends Model {
},
{
sequelize,
modelName: 'user'
modelName: 'user',
hooks: {
beforeDestroy(user) {
if (user.type === 'root') {
throw new Error('Root user cannot be deleted')
}
}
}
}
)
}