I would like to force a user password reset in Flutter on the first time login only. I have a field called "ChangePassword" in my firestore document field.
When I query this field I want to show a popup message that the user cannot use the app until the password is changed.
How do I do that in Flutter?
Here is where the login button is clicked
CustomButton(
onPressed: () {
if (_formkey.currentState!.validate()) {
Map<String, dynamic> map = {
'email': email.text,
'password': password.text,
};
model.login(context: context, map: map);
// });
} else {}
},
text: 'Login',
),
When the user enters in their credentials and clicks the "Login" button I navigate to this method
Future<void> login({
required BuildContext context,
required Map<String, dynamic> map,
}) async {
EasyLoading.show();
var response = await loginUsecase.call(map);
response.fold((l) {
Logger().d('Erroor');
EasyLoading.dismiss();
}, (r) {
// Logger().d(r.toJson());
// Logger().d(_credential);
SharedPref.setString(kEMAIL, map[kEMAIL]);
SharedPref.setString(kPASSWORD, map[kPASSWORD]);
SharedPref.setBool(kLocalAuthSetted, true);
EasyLoading.dismiss();
Get.toNamed(AppRoutes.main);
});
}
What I want to do is intercept this method and query the user table called "Users" and check if this user based on the email entered, has the key "ChangePassword" set to true If it is set to true I want to show a message that the password needs to be changed and then re-route them to the forgot password screen.
below i am just trying to pass the logic ,so please use it according to your approach and let me know any.
also you can query with both of the field at the same time like below
so you need to select what approach is best for you as according to your str.