Skip to content

Commit

Permalink
Fix logout functionality and remove console.log statement
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshchoudhary committed Jan 6, 2024
1 parent 5d3bea9 commit 7c91a52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ const logoutUser = asyncHandler(async(req, res) => {
await User.findByIdAndUpdate(
req.user._id,
{
$set: {
refreshToken: undefined
$unset: {
refreshToken: 1 // this removes the field from document
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/auth.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const verifyJWT = asyncHandler(async(req, _, next) => {
try {
const token = req.cookies?.accessToken || req.header("Authorization")?.replace("Bearer ", "")

console.log(token);
// console.log(token);
if (!token) {
throw new ApiError(401, "Unauthorized request")
}
Expand Down
5 changes: 3 additions & 2 deletions src/routes/user.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
updateUserAvatar,
updateUserCoverImage,
getUserChannelProfile,
getWatchHistory
getWatchHistory,
updateAccountDetails
} from "../controllers/user.controller.js";
import {upload} from "../middlewares/multer.middleware.js"
import { verifyJWT } from "../middlewares/auth.middleware.js";
Expand Down Expand Up @@ -41,7 +42,7 @@ router.route("/current-user").get(verifyJWT, getCurrentUser)
router.route("/update-account").patch(verifyJWT, updateAccountDetails)

router.route("/avatar").patch(verifyJWT, upload.single("avatar"), updateUserAvatar)
router.route("/cover-image").patch(verifyJWT, upload.single("/coverImage"), updateUserCoverImage)
router.route("/cover-image").patch(verifyJWT, upload.single("coverImage"), updateUserCoverImage)

router.route("/c/:username").get(verifyJWT, getUserChannelProfile)
router.route("/history").get(verifyJWT, getWatchHistory)
Expand Down

0 comments on commit 7c91a52

Please sign in to comment.