intermediate
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import 'package:lensai/features/user/domain/repositories/auth.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'controllers.g.dart';
|
||||
|
||||
@Riverpod()
|
||||
class AuthController extends _$AuthController {
|
||||
@override
|
||||
FutureOr<void> build() {}
|
||||
|
||||
Future<void> authWithPassword(String user, String password) async {
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(
|
||||
() => ref
|
||||
.read(authRepositoryProvider.notifier)
|
||||
.authWithPassword(user, password),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> registerWithPassword(String user, String password) async {
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(() {
|
||||
final repo = ref.read(authRepositoryProvider.notifier);
|
||||
return repo
|
||||
.createUserWithPassword(user, password)
|
||||
.then((_) => repo.authWithPassword(user, password));
|
||||
});
|
||||
}
|
||||
|
||||
void clearState() {
|
||||
state = const AsyncValue.data(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'controllers.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$authControllerHash() => r'5b56651948683d669f29946fe02bdb004f436afb';
|
||||
|
||||
/// See also [AuthController].
|
||||
@ProviderFor(AuthController)
|
||||
final authControllerProvider =
|
||||
AutoDisposeAsyncNotifierProvider<AuthController, void>.internal(
|
||||
AuthController.new,
|
||||
name: r'authControllerProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$authControllerHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AuthController = AutoDisposeAsyncNotifier<void>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
Reference in New Issue
Block a user