mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +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/navigation_service.dart';
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
import 'package:syncrow_app/services/api/authentication_api.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/helpers/snack_bar.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||||
part 'auth_state.dart';
|
part 'auth_state.dart';
|
||||||
|
|
||||||
class AuthCubit extends Cubit<AuthState> {
|
class AuthCubit extends Cubit<AuthState> {
|
||||||
@ -267,9 +269,21 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
|
|
||||||
getTokenAndValidate() async {
|
getTokenAndValidate() async {
|
||||||
emit(AuthTokenLoading());
|
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"));
|
emit(AuthTokenError(message: "Token not found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,33 @@
|
|||||||
// ignore_for_file: lines_longer_than_80_chars, constant_identifier_names
|
|
||||||
|
|
||||||
class StringsManager {
|
class StringsManager {
|
||||||
static const noRouteFound = 'No route found';
|
static const String noRouteFound = 'No route found';
|
||||||
static const noInternetConnection = 'No internet connection';
|
static const String noInternetConnection = 'No internet connection';
|
||||||
|
static const String dashboard = 'Dashboard';
|
||||||
static const dashboard = 'Dashboard';
|
static const String devices = 'Devices';
|
||||||
static const devices = 'Devices';
|
static const String routine = 'Routines';
|
||||||
static const routine = 'Routines';
|
static const String tapToRunRoutine = 'Tap to run routine';
|
||||||
static const tapToRunRoutine = 'Tap to run routine';
|
static const String wizard = 'Wizard';
|
||||||
static const wizard = 'Wizard';
|
static const String active = 'Active';
|
||||||
static const active = 'Active';
|
static const String current = 'Current';
|
||||||
static const current = 'Current';
|
static const String frequency = 'Frequency';
|
||||||
static const frequency = 'Frequency';
|
static const String energyUsage = 'Energy Usage';
|
||||||
static const energyUsage = 'Energy Usage';
|
static const String totalConsumption = 'Total Consumption';
|
||||||
static const totalConsumption = 'Total Consumption';
|
static const String ACConsumption = 'AC Consumption';
|
||||||
static const ACConsumption = 'AC Consumption';
|
static const String units = 'Units';
|
||||||
static const units = 'Units';
|
static const String emissions = 'Emissions';
|
||||||
static const emissions = 'Emissions';
|
static const String reductions = 'Reductions';
|
||||||
static const reductions = 'Reductions';
|
static const String winter = 'Winter';
|
||||||
static const winter = 'Winter';
|
static const String winterMode = 'Winter Mode';
|
||||||
static const winterMode = 'Winter Mode';
|
static const String summer = 'Summer';
|
||||||
static const summer = 'Summer';
|
static const String summerMode = 'Summer Mode';
|
||||||
static const summerMode = 'Summer Mode';
|
static const String on = 'ON';
|
||||||
static const on = 'ON';
|
static const String off = 'OFF';
|
||||||
static const off = 'OFF';
|
static const String timer = 'Timer';
|
||||||
static const timer = 'Timer';
|
static const String dimmerAndColor = "Dimmer & color";
|
||||||
static const dimmerAndColor = "Dimmer & color";
|
static const String recentlyUsed = "Recently used colors";
|
||||||
static const recentlyUsed = "Recently used colors";
|
static const String lightingModes = "Lighting modes";
|
||||||
static const lightingModes = "Lighting modes";
|
static const String doze = "Doze";
|
||||||
static const doze = "Doze";
|
static const String relax = "Relax";
|
||||||
static const relax = "Relax";
|
static const String reading = "Reading";
|
||||||
static const reading = "Reading";
|
static const String energizing = "Energizing";
|
||||||
static const energizing = "Energizing";
|
static const String firstLaunch = "firstLaunch";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user