36 lines
821 B
Dart
36 lines
821 B
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
|
|
class FirebaseAuthService {
|
|
final FirebaseAuth _auth = FirebaseAuth.instance;
|
|
|
|
Future<User?> signUpWithEmailAndPassword(
|
|
String email,
|
|
String password,
|
|
) async {
|
|
try {
|
|
UserCredential credential = await _auth.createUserWithEmailAndPassword(
|
|
email: email,
|
|
password: password,
|
|
);
|
|
return credential.user;
|
|
} on FirebaseAuthException {
|
|
rethrow; // lempar ulang ke pemanggil
|
|
}
|
|
}
|
|
|
|
Future<User?> signInWithEmailAndPassword(
|
|
String email,
|
|
String password,
|
|
) async {
|
|
try {
|
|
UserCredential credential = await _auth.signInWithEmailAndPassword(
|
|
email: email,
|
|
password: password,
|
|
);
|
|
return credential.user;
|
|
} on FirebaseAuthException {
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|