mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 22:19:26 +00:00
Fully implemented Class.removeUser
This commit is contained in:
29
lib/Class.js
29
lib/Class.js
@@ -231,14 +231,27 @@ class Class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser(u) {
|
async removeUser(u) {
|
||||||
switch (u.type) {
|
const validTypes = [ 'account', 'student' ];
|
||||||
case 'account':
|
|
||||||
break;
|
if (!validTypes.includes(u.type))
|
||||||
case 'student':
|
throw new Error('Invalid user type');
|
||||||
break;
|
|
||||||
default:
|
const sql = `
|
||||||
throw new Error('Invalid user type');
|
delete from ${u.type}ClassLink
|
||||||
|
where
|
||||||
|
${u.type}id = ?
|
||||||
|
and classId = ?;
|
||||||
|
`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.#conn.runQuery(sql, [
|
||||||
|
u.id,
|
||||||
|
this.id
|
||||||
|
]);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
throw new Error('Could not remove user from class');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user