Project/flutter_firebase_blog
5. firebase auth, firebase cloud storage를 활용하여 email, password 로그인 구현
MG_conny
2021. 7. 24. 00:27
로그인 버튼 함수
UserController.to.login(_email.text.trim(), _password.text.trim());
UserController
Future<void> login(String email, String password) async {
String result = await _userRepository.login(email, password);
if (result == "success") {
print("success");
} else if (result == "user-not-found") {
print('No user found for that email.');
} else if (result == "wrong-password") {
print('Wrong password provided for that user.');
} else {
print(result);
}
}
LoginReqDto
class LoginReqDto {
final String? email;
final String? password;
LoginReqDto(this.email, this.password);
Map<String, dynamic> toJson() => {
"email": email,
"password": password,
};
}
UserRepository
Future<String> login(String email, String password) async {
LoginReqDto dto = LoginReqDto(email, password);
try {
await _userProvider.login(dto);
return "success";
} on FirebaseAuthException catch (e) {
return e.code;
}
}
UserProvider
Future<UserCredential> login(LoginReqDto dto) async =>
await auth.signInWithEmailAndPassword(
email: dto.email.toString(), password: dto.password.toString());
Git Commit
https://github.com/mugon-dev/flutter_firebase_blog/commit/d5a51d681816c3759436585345cbf2d4fc39dab4
email, password, username 회원가입, 로그인, 로그아웃 구현 및 클라우드 저장 · mugon-dev/flutter_firebase_blo
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files email, password, username 회원가입, 로그인, 로그아웃 구현 및 클라우드 저장 Loading branch informati
github.com
728x90