Skip to content

Commit

Permalink
Fix bug in addNewRole (#29)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
schiltz3 authored Sep 6, 2022
2 parents eebe820 + fd8b571 commit 1f391bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rolesOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ export async function addNewRole<T extends IRole>(
) {
// This function is triggered when a user changes their role, it adds the new role to the user
let role;
switch (model.constructor) {
case classModel:
switch (model.modelName) {
case "class":
//TODO: Rewrite IRole to include name, and replace CODE with name
role = await model.findOne({ CODE: id });
break;
default:
role = await model.findOne({ Name: id });
role = await model.findOne({ NAME: id });
}

if (role === null) {
Expand Down

0 comments on commit 1f391bf

Please sign in to comment.