私の答えが役立つと思います。クラウド機能を使用してfirebase-adminでパスワードを変更できます。クライアント側からメールと新しいパスワードを渡すだけです(Angular、ionic、...)
クラウド機能:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
const cors = require('cors')({ origin: true });
export const resetUserPassword = functions.https.onRequest( async (req, res) => {
return cors( req, res, async () => {
const email = req.body.data.email;
const password = req.body.data.password;
admin.auth().getUserByEmail(email)
.then((getUserRecord) => {
admin.auth().updateUser(getUserRecord.uid, {
email,
password
})
.then(function(userRecord) {
res.send({
status: 200,
data: userRecord
})
})
.catch(function(error) {
res.send({
status: 500,
data: error
})
});
})
.catch((error) => {
console.log('Error fetching user data:', error);
});
})
});
クライアント側コード (IONIC):
import { AngularFireFunctions } from '@angular/fire/functions';
export class AuthService {
constructor(
private functions: AngularFireFunctions
) {}
resetUserPassword() {
const userNewCredential = {email: 'user-email', password: 'your-new-password'};
this.functions.httpsCallable('resetUserPassword')
(userNewCredential).toPromise().then((updatedUser) => {
console.log(updatedUser);
}).catch((error) => console.log(error));
}