Change user password within the app

Hello,

I’m trying to create a screen where the user can update their password. I’m trying to do this within the app. I don’t see any functionality for this in the FB Sign In Block so I thought about accessing the Firebase REST API directly to change a user’s password. After some research though I see that the API needs a user token which Thunkable doesn’t seem to provide.

I tried the API process with the user ID it didn’t work.

Is there another way to do this? It seems like a simple feature.

Thanks in advance.

You can do it with a google cloud function. Not too crazy. I just set one up this weekend.

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const auth = admin.auth();
const db = admin.firestore();
const cors = require('cors')({ origin: true });

module.exports.updateUser = async function (req, res) {
    cors( req, res, async () => {
       // const pw = req.body.password;
       const pw = req.body.password;
        const uid = req.body.uid;    
           try {
                await auth.updateUser(uid, {
                    password: pw,
                })
            res.status(200).send('User updated')
        } catch (error) {
            console.log(error)
            res.status(400).send(error)
        }
    })
   

}

My next plan is to update this to require authentication.

1 Like

Assuming that you need to change an application user password (as you mentioned FB SignIn block), why not use SignIn - Reset password block ?
screen
I know, this is when you forget a password, but it’s the easiest way to change it too…

1 Like