Load server configuration
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'package:moneymgr_mobile/services/api/api_client.dart';
|
||||
import 'package:moneymgr_mobile/services/api/api_token.dart';
|
||||
import 'package:moneymgr_mobile/services/api/auth_api.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/secure_storage.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@ -25,7 +26,10 @@ class CurrentAuthState extends _$CurrentAuthState {
|
||||
/// Will invalidate the state if success and throw an exception in case of failure
|
||||
Future<void> setAuthToken(ApiToken token) async {
|
||||
// Attempt to use provided token
|
||||
await ApiClient(token: token).authInfo();
|
||||
await ApiClient(
|
||||
token: token,
|
||||
prefs: await ref.watch(prefsProvider.future),
|
||||
).authInfo();
|
||||
|
||||
final secureStorage = ref.read(secureStorageProvider).requireValue;
|
||||
await secureStorage.setToken(token);
|
||||
@ -37,19 +41,13 @@ class CurrentAuthState extends _$CurrentAuthState {
|
||||
|
||||
/// Logs out, deletes the saved token and profile info from storage, and invalidates
|
||||
/// the state.
|
||||
void logout() {
|
||||
// TODO : implement logic
|
||||
/*final secureStorage = ref.read(secureStorageProvider).requireValue;
|
||||
|
||||
// Delete the current [token] and [profile] from secure storage.
|
||||
secureStorage.remove('token');
|
||||
Future<void> logout() async {
|
||||
final secureStorage = ref.read(secureStorageProvider).requireValue;
|
||||
await secureStorage.removeToken();
|
||||
|
||||
ref
|
||||
// Invalidate the state so the auth state will be updated to unauthenticated.
|
||||
..invalidateSelf()
|
||||
// Invalidate the token provider so the API service will no longer use the
|
||||
// previous token.
|
||||
..invalidate(tokenProvider);*/
|
||||
// Invalidate the state so the auth state will be updated to authenticated.
|
||||
.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user