Fix auth
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<application
|
<application
|
||||||
android:label="bmmanager"
|
android:label="bmmanager"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
|
|||||||
@@ -9,14 +9,27 @@ import 'brandmeister_client.dart';
|
|||||||
class AuthenticationManager extends ChangeNotifier {
|
class AuthenticationManager extends ChangeNotifier {
|
||||||
static const String _tokenKey = 'apiToken';
|
static const String _tokenKey = 'apiToken';
|
||||||
|
|
||||||
final FlutterSecureStorage _storage = const FlutterSecureStorage(
|
late final FlutterSecureStorage _storage;
|
||||||
|
|
||||||
|
AuthenticationManager() {
|
||||||
|
_initStorage();
|
||||||
|
_loadToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initStorage() {
|
||||||
|
_storage = const FlutterSecureStorage(
|
||||||
aOptions: AndroidOptions(
|
aOptions: AndroidOptions(
|
||||||
encryptedSharedPreferences: true,
|
encryptedSharedPreferences: true,
|
||||||
),
|
),
|
||||||
iOptions: IOSOptions(
|
iOptions: IOSOptions(
|
||||||
accessibility: KeychainAccessibility.first_unlock,
|
accessibility: KeychainAccessibility.first_unlock,
|
||||||
),
|
),
|
||||||
|
webOptions: WebOptions(
|
||||||
|
dbName: 'bmmanager',
|
||||||
|
publicKey: 'bmmanager_public_key',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bool _isAuthenticated = false;
|
bool _isAuthenticated = false;
|
||||||
String _apiToken = '';
|
String _apiToken = '';
|
||||||
@@ -27,10 +40,6 @@ class AuthenticationManager extends ChangeNotifier {
|
|||||||
String get apiToken => _apiToken;
|
String get apiToken => _apiToken;
|
||||||
UserInfo? get userInfo => _userInfo;
|
UserInfo? get userInfo => _userInfo;
|
||||||
|
|
||||||
AuthenticationManager() {
|
|
||||||
_loadToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadToken() async {
|
Future<void> _loadToken() async {
|
||||||
try {
|
try {
|
||||||
final token = await _storage.read(key: _tokenKey);
|
final token = await _storage.read(key: _tokenKey);
|
||||||
|
|||||||
@@ -8,5 +8,11 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.network.server</key>
|
<key>com.apple.security.network.server</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>$(TeamIdentifierPrefix)io.kida.bmmanager</string>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -4,5 +4,11 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.app-sandbox</key>
|
<key>com.apple.security.app-sandbox</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>$(TeamIdentifierPrefix)io.kida.bmmanager</string>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Reference in New Issue
Block a user