Skip to content
Snippets Groups Projects
Commit 3363aa3c authored by Quentin Bramas's avatar Quentin Bramas
Browse files

use the same name format when deleting users

parent e5ff8cc9
Branches
Tags v0.5
No related merge requests found
Pipeline #335276 passed with stages
in 1 minute and 43 seconds
......@@ -473,10 +473,7 @@ io.on('connection', function (socket) {
const toBeDeleted = [];
let nb_delete = 0;
for (let name of options) {
if (!name.startsWith(socket.user.name + '_')) {
socket.emit('sudo-error', 'you are not allowed to delete user ' + name);
return;
}
name = socket.user.name + '_' + name;
toBeDeleted.push(name);
let user = await db.Users.get({ username: name });
if (user) {
......@@ -489,6 +486,7 @@ io.on('connection', function (socket) {
socket.emit('sudo-result', 'deletion cancelled');
return;
}
names_check = names_check.map(n => socket.user.name + '_' + n);
// check if the names are the same
for (let name of names_check) {
if (!toBeDeleted.includes(name)) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment