'Error: [firebase_auth/invalid-email] The email address is badly formatted
String adminEmail = "";
String adminPassword = "";
allowAdminLogin() async {
SnackBar snackBar = const SnackBar(
content: Text(
"Checking Credentials Please wait .....",
style: TextStyle(
fontSize: 36,
color: Colors.black,
),
),
backgroundColor: Colors.pinkAccent,
duration: Duration(seconds: 6),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
User? currentAdmin;
await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: adminEmail,
password: adminPassword,
)
.then((fAuth) {
currentAdmin = fAuth.user;
});
if (currentAdmin != null) {
///check if that admin record also exists in the admins collection in firestore database,
await FirebaseFirestore.instance
.collection('admins')
.doc(currentAdmin!.uid)
.get().then((snap) {
if (snap.exists) {
Navigator.push(
context, MaterialPageRoute(builder: (c) => const HomeScreen()));
} else {
SnackBar snackBar = const SnackBar(
content: Text(
"No record found ,Checking Credentials, you are not an admin.",
style: TextStyle(
fontSize: 36,
color: Colors.black,
),
),
backgroundColor: Colors.pinkAccent,
duration: Duration(seconds: 6),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
});
}
}
Solution 1:[1]
you are trying to authenticate the email
String adminEmail = "";
which is not a valid email, so firebase will not authenticate it. you need to make sure that the email is valid.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tareq albeesh |
