Skip to content

Commit

Permalink
Autorização para o User trocar a senha
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Mar 14, 2022
1 parent f12892f commit 6fab280
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/src/controllers/UserController.ts
Expand Up @@ -67,11 +67,16 @@ export const update = async (
req: Request,
res: Response
): Promise<Response> => {
if (req.user.profile !== "admin") {
const { userId } = req.params;

const newUserId = userId.toString();
const sessionUserId = req.user.id.toString();

if (req.user.profile !== "admin" && sessionUserId !== newUserId) {
throw new AppError("ERR_NO_PERMISSION", 403);
}

const { userId } = req.params;
//const { userId } = req.params;
const userData = req.body;

const user = await UpdateUserService({ userData, userId });
Expand Down

0 comments on commit 6fab280

Please sign in to comment.