我刚刚完成了我的第一个应用程序的Firebase Auth,但我想在用户注册时添加电子邮件验证,请问我如何才能做到这一点。
class AuthServices {
final auth.FirebaseAuth _firebaseAuth = auth.FirebaseAuth.instance;
Login? _userFromFirebase(auth.User? user) {
if (user == null) {
return null;
}
return Login(user.uid, user.email);
}
Stream<Login?>? get user {
return _firebaseAuth.authStateChanges().map(_userFromFirebase);
}
Future<Login?> signUp(String email, String password, String name) async {
final credential = await _firebaseAuth.createUserWithEmailAndPassword(
email: email, password: password);
UserService().createUser(name);
return _userFromFirebase(credential.user);
}
Future<Login?> signIn(String email, String password) async {
final credential = await _firebaseAuth.signInWithEmailAndPassword(
email: email, password: password);
return _userFromFirebase(credential.user);
}
Future<void> signOut() async {
return await _firebaseAuth.signOut();
}
}
2条答案
按热度按时间xesrikrc1#
这将做你的工作:-
cuxqih212#