1 - multi module in Auth select save selected module
 2 - add flutter gen for assets builder
This commit is contained in:
2025-05-19 16:16:33 +03:30
parent 982329a3eb
commit 905e407ccd
46 changed files with 1431 additions and 407 deletions

View File

@@ -1,20 +1,26 @@
import 'dart:convert';
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
import 'package:rasadyar_auth/hive_registrar.g.dart';
import 'package:rasadyar_core/core.dart';
class TokenStorageService extends GetxService {
static const String _boxName = 'secureBox';
static const String _accessTokenKey = 'accessToken';
static const String _refreshTokenKey = 'refreshToken';
static const String _moduleKey = 'moduleSelected';
final FlutterSecureStorage _secureStorage = FlutterSecureStorage();
final HiveLocalStorage _localStorage = diCore.get<HiveLocalStorage>();
RxnString accessToken = RxnString();
RxnString refreshToken = RxnString();
RxnString tsss = RxnString();
RxnString accessToken = RxnString();
RxnString refreshToken = RxnString();
Rxn<Module> appModule = Rxn(null);
Future<void> init() async {
Hive.registerAdapters();
IsolatedHive.registerAdapters();
final String? encryptedKey = await _secureStorage.read(key: 'hive_enc_key');
final encryptionKey =
encryptedKey != null
@@ -42,6 +48,10 @@ class TokenStorageService extends GetxService {
boxName: _boxName,
key: _refreshTokenKey,
);
appModule.value = _localStorage.read<Module?>(
boxName: _boxName,
key: _moduleKey,
);
}
Future<void> saveAccessToken(String token) async {
@@ -64,6 +74,12 @@ class TokenStorageService extends GetxService {
refreshToken.refresh();
}
Future<void> saveModule(Module input) async {
await _localStorage.save(boxName: _boxName, key: _moduleKey, value: input);
appModule.value = input;
appModule.refresh();
}
Future<void> deleteTokens() async {
await _localStorage.clear(_boxName);
accessToken.value = null;