strip auth
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:riverpod/riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/features/user/data/providers.dart';
|
||||
@@ -21,35 +20,6 @@ Stream<double> iconCacheSizeMegabytes(Ref ref) {
|
||||
return repository.cacheDao.getIconCacheSize().watchSingle();
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AsyncAuthStore authStore(Ref ref) {
|
||||
const secureStorage = FlutterSecureStorage();
|
||||
|
||||
final intial = ref.watch(
|
||||
_storedAuthDataProvider.select((value) => value.valueOrNull),
|
||||
);
|
||||
|
||||
return AsyncAuthStore(
|
||||
initial: intial,
|
||||
save: (data) async {
|
||||
await secureStorage.write(key: _authKey, value: data);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
Stream<AuthStoreEvent> authState(Ref ref) {
|
||||
final authStore = ref.watch(authStoreProvider);
|
||||
return authStore.onChange;
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
PocketBase pocketBase(Ref ref) {
|
||||
final authStore = ref.watch(authStoreProvider);
|
||||
|
||||
return PocketBase('http://192.168.2.104:8090', authStore: authStore);
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
bool incognitoModeEnabled(Ref ref) {
|
||||
return ref.watch(
|
||||
|
||||
@@ -44,54 +44,6 @@ final iconCacheSizeMegabytesProvider =
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef IconCacheSizeMegabytesRef = AutoDisposeStreamProviderRef<double>;
|
||||
String _$authStoreHash() => r'766c001bbb8d7dc4e148eff3816c414d78e77f26';
|
||||
|
||||
/// See also [authStore].
|
||||
@ProviderFor(authStore)
|
||||
final authStoreProvider = Provider<AsyncAuthStore>.internal(
|
||||
authStore,
|
||||
name: r'authStoreProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$authStoreHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef AuthStoreRef = ProviderRef<AsyncAuthStore>;
|
||||
String _$authStateHash() => r'ffa411ae0abc5c7bb3e8a93e783bd8398ce7f666';
|
||||
|
||||
/// See also [authState].
|
||||
@ProviderFor(authState)
|
||||
final authStateProvider = AutoDisposeStreamProvider<AuthStoreEvent>.internal(
|
||||
authState,
|
||||
name: r'authStateProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$authStateHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef AuthStateRef = AutoDisposeStreamProviderRef<AuthStoreEvent>;
|
||||
String _$pocketBaseHash() => r'9e1dc8057e300bc7ca697da9f68ec61e70fdbaab';
|
||||
|
||||
/// See also [pocketBase].
|
||||
@ProviderFor(pocketBase)
|
||||
final pocketBaseProvider = Provider<PocketBase>.internal(
|
||||
pocketBase,
|
||||
name: r'pocketBaseProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$pocketBaseHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef PocketBaseRef = ProviderRef<PocketBase>;
|
||||
String _$incognitoModeEnabledHash() =>
|
||||
r'3968c2d4945be09a0bc08ce0d70b0390187c44e8';
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/features/user/domain/entities/auth_exception.dart';
|
||||
import 'package:weblibre/features/user/domain/providers.dart';
|
||||
import 'package:weblibre/features/user/extensions/client_exception.dart';
|
||||
|
||||
part 'auth.g.dart';
|
||||
|
||||
@Riverpod()
|
||||
class AuthRepository extends _$AuthRepository {
|
||||
late PocketBase _pb;
|
||||
|
||||
Future<RecordAuth> authWithPassword(String user, String password) async {
|
||||
try {
|
||||
return await _pb.collection('users').authWithPassword(user, password);
|
||||
} on ClientException catch (e) {
|
||||
throw AuthException(e.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<RecordModel> createUserWithPassword(
|
||||
String email,
|
||||
String password,
|
||||
) async {
|
||||
try {
|
||||
return await _pb
|
||||
.collection('users')
|
||||
.create(
|
||||
body: {
|
||||
"email": email,
|
||||
"password": password,
|
||||
"passwordConfirm": password,
|
||||
},
|
||||
);
|
||||
} on ClientException catch (e) {
|
||||
throw AuthException(e.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void build() {
|
||||
_pb = ref.watch(pocketBaseProvider);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$authRepositoryHash() => r'90ea6f082ef968831763c7f7ee31863f1fe329fe';
|
||||
|
||||
/// See also [AuthRepository].
|
||||
@ProviderFor(AuthRepository)
|
||||
final authRepositoryProvider =
|
||||
AutoDisposeNotifierProvider<AuthRepository, void>.internal(
|
||||
AuthRepository.new,
|
||||
name: r'authRepositoryProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$authRepositoryHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AuthRepository = AutoDisposeNotifier<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