Skip to content

Commit 1f391bf

Browse files
authored
Fix bug in addNewRole (#29)
Fixes bug introduced in #22 Where roles were not being retrieved from the db correctly - switch on the wrong field - forgot `break` - didn't capitalize the query field
2 parents eebe820 + fd8b571 commit 1f391bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

rolesOps.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ export async function addNewRole<T extends IRole>(
6363
) {
6464
// This function is triggered when a user changes their role, it adds the new role to the user
6565
let role;
66-
switch (model.constructor) {
67-
case classModel:
66+
switch (model.modelName) {
67+
case "class":
6868
//TODO: Rewrite IRole to include name, and replace CODE with name
6969
role = await model.findOne({ CODE: id });
70+
break;
7071
default:
71-
role = await model.findOne({ Name: id });
72+
role = await model.findOne({ NAME: id });
7273
}
7374

7475
if (role === null) {

0 commit comments

Comments
 (0)