mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 14:37:56 +00:00
Fixed token issue
This commit is contained in:
@@ -8,7 +8,9 @@ import 'package:syncrow_app/features/auth/model/user_model.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/services/api/authentication_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/shared_preferences_helper.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||
part 'auth_state.dart';
|
||||
|
||||
class AuthCubit extends Cubit<AuthState> {
|
||||
@@ -267,9 +269,21 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
|
||||
getTokenAndValidate() async {
|
||||
emit(AuthTokenLoading());
|
||||
final value = await const FlutterSecureStorage().read(key: Token.loginAccessTokenKey);
|
||||
const storage = FlutterSecureStorage(
|
||||
aOptions: AndroidOptions(
|
||||
encryptedSharedPreferences: true,
|
||||
));
|
||||
final firstLaunch =
|
||||
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
|
||||
|
||||
if (value == null || value.isEmpty) {
|
||||
if (firstLaunch) {
|
||||
storage.deleteAll();
|
||||
}
|
||||
|
||||
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
|
||||
|
||||
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
||||
if (value.isEmpty) {
|
||||
emit(AuthTokenError(message: "Token not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user