Fix auth
This commit is contained in:
@@ -9,14 +9,27 @@ import 'brandmeister_client.dart';
|
||||
class AuthenticationManager extends ChangeNotifier {
|
||||
static const String _tokenKey = 'apiToken';
|
||||
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage(
|
||||
aOptions: AndroidOptions(
|
||||
encryptedSharedPreferences: true,
|
||||
),
|
||||
iOptions: IOSOptions(
|
||||
accessibility: KeychainAccessibility.first_unlock,
|
||||
),
|
||||
);
|
||||
late final FlutterSecureStorage _storage;
|
||||
|
||||
AuthenticationManager() {
|
||||
_initStorage();
|
||||
_loadToken();
|
||||
}
|
||||
|
||||
void _initStorage() {
|
||||
_storage = const FlutterSecureStorage(
|
||||
aOptions: AndroidOptions(
|
||||
encryptedSharedPreferences: true,
|
||||
),
|
||||
iOptions: IOSOptions(
|
||||
accessibility: KeychainAccessibility.first_unlock,
|
||||
),
|
||||
webOptions: WebOptions(
|
||||
dbName: 'bmmanager',
|
||||
publicKey: 'bmmanager_public_key',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _isAuthenticated = false;
|
||||
String _apiToken = '';
|
||||
@@ -27,10 +40,6 @@ class AuthenticationManager extends ChangeNotifier {
|
||||
String get apiToken => _apiToken;
|
||||
UserInfo? get userInfo => _userInfo;
|
||||
|
||||
AuthenticationManager() {
|
||||
_loadToken();
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
try {
|
||||
final token = await _storage.read(key: _tokenKey);
|
||||
|
||||
Reference in New Issue
Block a user