Search
 
SCRIPT & CODE EXAMPLE
 

DART

change password firebase flutter

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;
  }
Comment

change password firebase flutter

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'},  
  )
}
Comment

PREVIOUS NEXT
Code Example
Dart :: how to get the display size of mobile display in flutter 
Dart :: text wrap in flutter 
Dart :: flutter two line list 
Dart :: flutter audio player get duration 
Dart :: looping through a list dart 
Dart :: open popupbutton onclick in flutter 
Dart :: math.round dart 
Dart :: flutter status bar color 
Dart :: after build flutter 
Dart :: flutter getx arguments 
Dart :: flutter refresh page 
Dart :: dart sort list by date 
Dart :: hellow world in dart 
Dart :: flutter listview inside a column 
Dart :: dart power operator 
Dart :: flutter get key from map 
Dart :: flutter performance tips 
Dart :: dart while 
Dart :: dart read csv files 
Dart :: fluter check that date is greater than another date 
Dart :: flutter ios status bar is dark 
Dart :: how to get isoCode based on location in flutter 
Dart :: how to get image file size in flutter 
Dart :: flutter component position absolute 
Dart :: align column to center of flex flutter 
Dart :: AnimatedCrossFade 
Dart :: list join dart 
Dart :: How to create maps in flutter 
Dart :: image not shoing when i use network image,flutter 
Dart :: dart svg drawer 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =