34 lines
779 B
Dart
34 lines
779 B
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
|
|
class AuthService {
|
|
static FirebaseAuth _auth = FirebaseAuth.instance;
|
|
|
|
static Future<User?> registerWithEmail({
|
|
required String email,
|
|
required String password,
|
|
}) async {
|
|
final credential = await _auth.createUserWithEmailAndPassword(
|
|
email: email,
|
|
password: password,
|
|
);
|
|
return credential.user;
|
|
}
|
|
|
|
static Future<User?> signInWithEmail({
|
|
required String email,
|
|
required String password,
|
|
}) async {
|
|
final credential = await _auth.signInWithEmailAndPassword(
|
|
email: email,
|
|
password: password,
|
|
);
|
|
return credential.user;
|
|
}
|
|
|
|
static Future<void> signOut() async {
|
|
await _auth.signOut();
|
|
}
|
|
|
|
static User? get currentUser => _auth.currentUser;
|
|
}
|