Skip to content
Snippets Groups Projects
Commit 36b81a9a authored by alrwasheda's avatar alrwasheda :speech_balloon:
Browse files

corrected according to last changes

parent 3385708b
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,11 @@ import bcrypt from "bcrypt";
const showCurrentUserController = async (req: Request, res: Response) => {
try {
const currentUser = res.locals.user; //payload
const currentUserData = await Worker.findByPk(currentUser.email);
const currentUserData = await Worker.findOne({
where: {
email: currentUser.email,
},
});
res.status(200).json({ success: true, result: currentUserData });
} catch (error) {
......@@ -31,11 +35,11 @@ const updateCurrentUser = async (req: Request, res: Response) => {
if (input.password !== undefined) {
input.password = await bcrypt.hash(input.password, 10);
}
const currentUser = res.locals.user;
const currentUserEmail = currentUser.email;
const currentUserEmail = currentUser.email; //updating data of current user: payload in token has the unique email + role
//update coordinator data
//update coordinator data after finding wanted user through found email
const workerDataAfterUpdate = await Worker.update(input, {
where: {
email: currentUserEmail,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment