Hi I have three enviroments two in clouding.io and other in AWS. Strapi v. 4.9, Node v.18. bcrypt v2.4.3.
plugin.controllers.user.updatePassword = async (ctx) => {
try{
const params = ctx.request.body;
// Get User based on identifier
if (!params.password || !params.new_password) {
return ctx.throw(400, "provide-currentPassword-newPassword-error");
}
let user = await strapi.db.query('plugin::users-permissions.user').findOne({id: ctx.state.user.id});
// Validate given password against user query result password
const validPassword = await strapi.plugins['users-permissions'].services.user.validatePassword(params.password, user.password);
// const validPassword = await strapi.service("plugin::users-permissions.user").validatePassword(params.password, user.password);
console.log(validPassword);
if (!validPassword) {
return ctx.throw(401, "wrong-current-password-error");
} else {
// Generate new hash password
const password = await bcrypt.hashSync(params.new_password, 10);
// Update user password
[...]
}
}catch(e){
console.log(e);
}
}
This works in a clouding but not in the other two (one clouding and Aws). It fails in validate password in thoth type of calls.
The error is: Illegal arguments: string, object
This topic has been created from a Discord post (1252533732720771183) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord