Skip to content

Commit

Permalink
Remove cache upon updated username
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Oct 25, 2024
1 parent 5c2f247 commit 8efa2b3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/src/controllers/userControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Verifier } from "academic-email-verifier";
import checkCollegeEmail from "../mail/checkAcademic";
import { registerSchema } from "../validation/registerSchema";
import redis from "../lib/redis";
import { deleteCachedPosts } from "../lib/redis";

const googleSignInOrSignUp = asyncHandler(
//@ts-ignore
Expand Down Expand Up @@ -640,7 +641,19 @@ const updateDetails = asyncHandler(async (req: Request, res: Response) => {
pic,
},
});
const college=await prisma.userCourse.findFirst({
where:{
user_id:userId
},
select:{
college_id:true
}
});
if(!college){
return res.status(404).json({ message: "User not found" });
}
await redis.del(`user:${userId}`);
await deleteCachedPosts(college.college_id);
return res.status(200).json({ message: "Details updated" });
});

Expand Down

0 comments on commit 8efa2b3

Please sign in to comment.