39 lines
987 B
Dart
39 lines
987 B
Dart
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
|
|
class AuthService {
|
|
const AuthService(this._client);
|
|
final SupabaseClient _client;
|
|
|
|
User? get currentUser => _client.auth.currentUser;
|
|
Session? get currentSession => _client.auth.currentSession;
|
|
Stream<AuthState> get onAuthStateChange => _client.auth.onAuthStateChange;
|
|
|
|
Future<AuthResponse> signUp({
|
|
required String email,
|
|
required String password,
|
|
required String username,
|
|
}) async {
|
|
return await _client.auth.signUp(
|
|
email: email,
|
|
password: password,
|
|
data: {'username': username},
|
|
);
|
|
}
|
|
|
|
Future<AuthResponse> login({
|
|
required String email,
|
|
required String password,
|
|
}) async {
|
|
return await _client.auth.signInWithPassword(
|
|
email: email,
|
|
password: password,
|
|
);
|
|
}
|
|
|
|
Future<void> logout() async => await _client.auth.signOut();
|
|
|
|
Future<void> forgotPassword(String email) async {
|
|
await _client.auth.resetPasswordForEmail(email);
|
|
}
|
|
}
|