1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-08 16:30:26 +00:00

#8776 resolve server crash on delete role in use (#8796)

This commit is contained in:
webplusai 2024-12-05 13:29:58 +01:00 committed by GitHub
parent ac59af19dd
commit d7eb39c88e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -38,15 +38,14 @@ POST /admin/delete-role
return;
}
// Delete the role
sqlTiddlerDatabase.deleteRole(role_id);
// Check if the role is in use
var isRoleInUse = sqlTiddlerDatabase.isRoleInUse(role_id);
if(isRoleInUse) {
sqlTiddlerDatabase.deleteUserRolesByRoleId(role_id);
}
// Delete the role
sqlTiddlerDatabase.deleteRole(role_id);
// Redirect back to the roles management page
response.writeHead(302, { "Location": "/admin/roles" });
response.end();

View File

@ -1156,7 +1156,7 @@ SqlTiddlerDatabase.prototype.deleteRole = function(roleId) {
SqlTiddlerDatabase.prototype.listRoles = function() {
return this.engine.runStatementGetAll(`
SELECT * FROM roles ORDER BY role_name
SELECT * FROM roles ORDER BY role_name DESC
`);
};