feat : auth for new module
This commit is contained in:
@@ -8,6 +8,8 @@ class TokenStorageService extends GetxService {
|
||||
static const String _boxName = 'secureBox';
|
||||
static const String _accessTokenKey = 'accessToken';
|
||||
static const String _refreshTokenKey = 'refreshToken';
|
||||
static const String _baseUrlKey = 'baseUrl';
|
||||
static const String _apiKey = 'apiKey';
|
||||
static const String _moduleKey = 'moduleSelected';
|
||||
|
||||
final FlutterSecureStorage _secureStorage = FlutterSecureStorage();
|
||||
@@ -15,6 +17,7 @@ class TokenStorageService extends GetxService {
|
||||
|
||||
RxnString accessToken = RxnString();
|
||||
RxnString refreshToken = RxnString();
|
||||
RxnString baseurl= RxnString();
|
||||
Rxn<Module> appModule = Rxn(null);
|
||||
|
||||
Future<void> init() async {
|
||||
@@ -34,6 +37,7 @@ class TokenStorageService extends GetxService {
|
||||
accessToken.value = _localStorage.read<String?>(boxName: _boxName, key: _accessTokenKey);
|
||||
refreshToken.value = _localStorage.read<String?>(boxName: _boxName, key: _refreshTokenKey);
|
||||
appModule.value = _localStorage.read<Module?>(boxName: _boxName, key: _moduleKey);
|
||||
baseurl.value = _localStorage.read<String?>(boxName: _boxName, key: _baseUrlKey);
|
||||
}
|
||||
|
||||
Future<void> saveAccessToken(String token) async {
|
||||
@@ -59,4 +63,16 @@ class TokenStorageService extends GetxService {
|
||||
accessToken.value = null;
|
||||
refreshToken.value = null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> saveBaseUrl(String url) async {
|
||||
await _localStorage.save(boxName: _boxName, key: _baseUrlKey, value: url);
|
||||
baseurl.value = url;
|
||||
baseurl.refresh();
|
||||
}
|
||||
|
||||
Future<void> saveApiKey(String key) async {
|
||||
await _localStorage.save(boxName: _boxName, key: _apiKey, value: key);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user