“Ändern Sie das Passwort Firebase Flattern” Code-Antworten

Ändern Sie das Passwort Firebase Flattern

Here's the latest method to change the password in firebase futter 2022
 
 Future<bool> _changePassword(String currentPassword, String newPassword) async {
    bool success = false;

    //Create an instance of the current user.
    var user = await FirebaseAuth.instance.currentUser!;
    //Must re-authenticate user before updating the password. Otherwise it may fail or user get signed out.

    final cred = await EmailAuthProvider.credential(email: user.email!, password: currentPassword);
    await user.reauthenticateWithCredential(cred).then((value) async {
      await user.updatePassword(newPassword).then((_) {
        success = true;
        usersRef.doc(uid).update({"password": newPassword});
      }).catchError((error) {
        print(error);
      });
    }).catchError((err) {
      print(err);
    });

    return success;
  }
MicroProgramer

Ändern Sie das Passwort Firebase Flattern

import 'package:http/http.dart' as http;
import 'dart:convert';
import 'dart:async';

Future<Null> changePassword(String newPassword) async {
  const String API_KEY = 'YOUR_API_KEY';
  final String changePasswordUrl =
      'https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=$API_KEY';

      final String idToken = await user.getIdToken(); // where user is FirebaseUser user

    final Map<String, dynamic> payload = {
      'email': idToken,
      'password': newPassword,
      'returnSecureToken': true
    };

  await http.post(changePasswordUrl, 
    body: json.encode(payload), 
    headers: {'Content-Type': 'application/json'},  
  )
}
The Codesmith

Ähnliche Antworten wie “Ändern Sie das Passwort Firebase Flattern”

Fragen ähnlich wie “Ändern Sie das Passwort Firebase Flattern”

Weitere verwandte Antworten zu “Ändern Sie das Passwort Firebase Flattern” auf Dart

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen