Skip to content

Commit

Permalink
error fix for reset password
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrahimi committed Jan 20, 2025
1 parent 2e913a5 commit c2c46f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.forgotPassword = async (req, res) => {
});

// Send reset email
const resetURL = `${req.protocol}://${req.get('host')}/api/v1/reset-password/${resetToken}`;
const resetURL = `${req.protocol}://${req.get('host')}/api/v1/change-password/${resetToken}`;
const message = `
<h2>Password Reset</h2>
<p>Click the link below to reset your password:</p>
Expand All @@ -46,6 +46,11 @@ exports.forgotPassword = async (req, res) => {
}
};

exports.changePassword = async(req, res) => {
console.log(req.params)
return res.status(200).json({ token: req.params.token, message: 'Password reset email sent' });
}

exports.resetPassword = async (req, res) => {

try {
Expand Down
3 changes: 2 additions & 1 deletion src/routes/authRouter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express = require('express');
const { loginUser } = require('../services/authService');
const { forgotPassword, resetPassword } = require('../controllers/authController');
const { forgotPassword, resetPassword, changePassword } = require('../controllers/authController');

const router = express.Router();

Expand Down Expand Up @@ -40,6 +40,7 @@ router.post('/logout', async (req, res) => {
});

router.post('/forgot-password', forgotPassword);
router.get('/change-password/:token', changePassword);
router.post('/reset-password/:token', resetPassword);

module.exports = router;

0 comments on commit c2c46f7

Please sign in to comment.