Skip to content

Commit

Permalink
#8776 resolve server crash on delete role in use (#8796)
Browse files Browse the repository at this point in the history
  • Loading branch information
webplusai authored Dec 5, 2024
1 parent ac59af1 commit d7eb39c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
`);
};

Expand Down

0 comments on commit d7eb39c

Please sign in to comment.