Skip to content

Commit

Permalink
fix: [sc-151] Missing returned updated user (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
gubbih authored Nov 15, 2023
2 parents 7be2725 + 39106a5 commit 553a0d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Src/Firebase/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ export async function userLogin(
);
}
//hashes password in routes intill i know a better way
export async function updateUser(user: User) {
if (!isValidUser(user)) {
throw new BaseError('User is not valid', 400);
}
export async function updateUser(user: User): Promise<User> {

const updateUser = doc(db, 'users', `${user.id}`);
await updateDoc(updateUser, {
firstName: user.firstName,
Expand All @@ -150,6 +148,7 @@ export async function updateUser(user: User) {
if (!updateUser) {
throw new BaseError('User not found', 404);
}
return user;
}

export async function deleteUser(user: User) {
Expand Down
4 changes: 2 additions & 2 deletions Src/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ router.put(
password: hashedPassword || user.password,
orgId: [parseInt(req.params.orgId)],
};
updateUser(updatedUser);
res.status(204).end();
const newUserInfo = await updateUser(updatedUser);
res.json(newUserInfo);
}),
);

Expand Down

0 comments on commit 553a0d8

Please sign in to comment.