First of all, I'm working with express in NodeJS.
I want to create an API call for updating the user's personal account informations.
Before doing this I should ask the user for the password for more security, this operation will be handled in this middleware isPasswordCorrect inside the request:
const isPasswordCorrect = (req, res, next) => { const password = req.password // perform the login call, to confirm the user identity // if password is correct call next() } I already created this endpoint to log in:
router.post('/login', (req, res) => { const { login, password } = req.body // do some logic for checking if the login data are correct res.json({"accessToken": accessToken}) }) So to facilitate the task, I want to call the above-mentionned login endpoint inside the middleware isPasswordCorrect, to check the identity of the user before updating his data