i faced this error while calling the query to the database to the clearDB . it returns the error i specified in the title... SELECT command denied to user @ for table ...... i uploaded my clearDB on heruko , i am using the express.js mysql2 npm package here's my code
here's my code
const promise = db.promise()
const {
newPass,
resetTocken
} = req.body
if (!newPass) return res.status(400).json({ msg: 'newPass is required!' })
if (newPass.length < 6) return res.status(400).json({ msg: 'atleast 6 digit password is required!' })
if (!resetTocken) return res.status(400).json({ msg: 'resetTocken is required!' })
const find_user_query = `
select *
from dotor_app_care.wp_users
where ID=?
`
const update_user_query = `
update wp_users
set user_pass=?
where ID=?
`
//verify tocken
jwt.verify(resetTocken, process.env.FORGOT_PASSWORD_SECRET, async (error, user) => {
if (error) return res.status(500).json({ msg: 'access denied!' })
if (user) {
console.log('user==>', user)
const [uR, uF] = await promise.execute(find_user_query, [user.id])
if (uR.length === 0) return res.status(400).json({ msg: 'no user found!' })
const encryptedPassword = CryptoJS.MD5(newPass).toString();
await promise.execute(update_user_query, [encryptedPassword, uR[0].ID])
return res.status(200).json({ msg: "password updated successfully!" })
}
})
The problem was in slecting the Table