Update user password with backend code

Because of my unique login flow, I have to ask users to create a password on a custom password creation page.

I’ve been trying to update the Members and Contacts backend collections with a password unsuccessfully.

Does anyone know if code like this should work? (It’s not working):

export function updateUserPassword( userId, password ){

 let userInfo = {
 "password": password
        };

    wixUsers.updateUserFields( userId, userInfo )
    .then( () => {
        //user has been updated
        console.log("user password has been updated in WixUsers");
    })
    .catch( (err) => {
        //there was an error
        console.log("error updating user password in WixUsers");
        console.log(err);
    });

    wixCrm.updateContact( userId, userInfo )
    .then( () => {
        //user has been updated
        console.log("user password has been updated in WixCrm");
    })
    .catch( (err) => {
        //there was an error
        console.log("error updating user password in WixCrm");
        console.log(err);
    });
}

I’m calling updateUserPassword from the frontend. My console.log shows the password has been updated for both wixUsers and wixCRM and I get no errors.

But then, I can’t log that user in.

I don’t see any documentation for this and the closest I’ve seen in the forums is this unresolved thread:

Please help… thanks.

You can’t physically change or update a users password, that is still currently only available through the Wix forgot password window which lets the user change their own password.
https://support.wix.com/en/article/site-members-password-retrieval
https://support.wix.com/en/article/request-customizing-the-reset-password-email

As stated on that previous forum post about it you can’t do it.
https://www.wix.com/corvid/forum/community-discussion/forgot-password-password-reset

You need to use wixUsers.promptForgotPassword();
https://www.wix.com/corvid/reference/wix-users.html#promptForgotPassword

Thanks, I’ll need a whisky to get over my sadness

I would also strongly echo the need for this. My mobile app hits the website through various backend APIs and I need to be able to offer the mobile user the ability to change their password without requiring them go through the Wix prompt for password flow.