first commit
This commit is contained in:
38
lib/features/auth/data/services/auth_service.dart
Normal file
38
lib/features/auth/data/services/auth_service.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user