forked from eatvio/eatvio_app
fix: token storage
This commit is contained in:
@@ -3,7 +3,7 @@ name: Eatvio App Android Test
|
||||
on: [ pull_request ]
|
||||
|
||||
env:
|
||||
flutter_version: "3.32.8"
|
||||
flutter_version: "3.35.1"
|
||||
java_version: "21.x"
|
||||
flutter_channel: "stable"
|
||||
my_local_cache_dir: "/opt/hostedtoolcache/"
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,6 +16,4 @@
|
||||
*.mocks.dart
|
||||
android/build/
|
||||
ios/XCBuildData/
|
||||
.env
|
||||
env.example
|
||||
env/.env
|
||||
@@ -29,7 +29,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.eatvioapp.app"
|
||||
minSdk = 23
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
|
||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-all.zip
|
||||
|
||||
@@ -18,11 +18,11 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "8.7.3" apply false
|
||||
id "com.android.application" version "8.12.0" apply false
|
||||
// START: FlutterFire Configuration
|
||||
id "com.google.gms.google-services" version "4.4.2" apply false
|
||||
id "com.google.gms.google-services" version "4.4.3" apply false
|
||||
// END: FlutterFire Configuration
|
||||
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "2.2.10" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:eatvio_app/core/env_config.dart';
|
||||
|
||||
String baseUrl = EnvConfig.baseUrl;
|
||||
String baseUrl = EnvConfig.devBaseUrl;
|
||||
bool hidePlans = const bool.fromEnvironment('HIDE_PLANS', defaultValue: false);
|
||||
const buildDate = String.fromEnvironment('BUILD_DATE', defaultValue: '');
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
abstract class CredentialsStorage {
|
||||
static Future<bool> haveCredentialsInStorage() async {
|
||||
static bool haveCredentialsInStorage() {
|
||||
try {
|
||||
if (await const FlutterSecureStorage().read(key: 'email') == null || await const FlutterSecureStorage().read(key: 'password') == null) {
|
||||
if (sl<SharedPreferences>().getString('email') == null || sl<SharedPreferences>().getString('password') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -13,20 +14,20 @@ abstract class CredentialsStorage {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, String>> getCredentialsFromStorage() async {
|
||||
static Map<String, String> getCredentialsFromStorage() {
|
||||
return {
|
||||
'email': (await const FlutterSecureStorage().read(key: 'email'))!,
|
||||
'password': (await const FlutterSecureStorage().read(key: 'password'))!,
|
||||
'email': (sl<SharedPreferences>().getString('email'))!,
|
||||
'password': (sl<SharedPreferences>().getString('password'))!,
|
||||
};
|
||||
}
|
||||
|
||||
static Future<void> saveCredentials(String email, String password) async {
|
||||
await const FlutterSecureStorage().write(key: 'email', value: email);
|
||||
await const FlutterSecureStorage().write(key: 'password', value: password);
|
||||
await sl<SharedPreferences>().setString('email', email);
|
||||
await sl<SharedPreferences>().setString('password', password);
|
||||
}
|
||||
|
||||
static Future<void> removeCredentials() async {
|
||||
await const FlutterSecureStorage().delete(key: 'email');
|
||||
await const FlutterSecureStorage().delete(key: 'password');
|
||||
sl<SharedPreferences>().remove('email');
|
||||
sl<SharedPreferences>().remove('password');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/se
|
||||
import 'package:eatvio_app/features/settings/repositories/service_repository.dart';
|
||||
import 'package:eatvio_app/features/settings/services/settings_service.dart';
|
||||
import 'package:eatvio_app/features/user_details/presentation/cubit/user_details_cubit.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/plans_cubit/plans_cubit.dart' as profile_plans;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
|
||||
@@ -252,5 +252,5 @@ Future<void> init() async {
|
||||
],
|
||||
),
|
||||
);
|
||||
sl.registerLazySingleton(() async => const FlutterSecureStorage());
|
||||
sl.registerLazySingleton(() async => SharedPreferences.getInstance());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'locator_service.dart';
|
||||
|
||||
abstract class TokenStorage {
|
||||
static Future<bool> haveTokenInStorage() async {
|
||||
static bool haveTokenInStorage() {
|
||||
try {
|
||||
if (await const FlutterSecureStorage().read(key: 'token') == null) {
|
||||
if (sl<SharedPreferences>().getString('token') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -13,19 +14,19 @@ abstract class TokenStorage {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String?> getTokenFromStorage() async => await const FlutterSecureStorage().read(key: 'token');
|
||||
static String? getTokenFromStorage() => sl<SharedPreferences>().getString('token');
|
||||
|
||||
static Future<void> saveTokenInStorage(String token) async {
|
||||
await const FlutterSecureStorage().write(key: 'token', value: token);
|
||||
await sl<SharedPreferences>().setString('token', token);
|
||||
}
|
||||
|
||||
static Future<void> removeTokenInStorage() async => (await const FlutterSecureStorage().delete(key: 'token'));
|
||||
static Future<void> removeTokenInStorage() async => (await sl<SharedPreferences>().remove('token'));
|
||||
}
|
||||
|
||||
abstract class SocketIdStorage {
|
||||
static Future<bool> haveSocketIdInStorage() async {
|
||||
static bool haveSocketIdInStorage() {
|
||||
try {
|
||||
if (await const FlutterSecureStorage().read(key: 'socketId') == null) {
|
||||
if (sl<SharedPreferences>().getString('socketId') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -35,11 +36,11 @@ abstract class SocketIdStorage {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String?> getSocketIdFromStorage() async => await const FlutterSecureStorage().read(key: 'socketId');
|
||||
static String? getSocketIdFromStorage() => sl<SharedPreferences>().getString('socketId');
|
||||
|
||||
static Future<void> saveSocketIdInStorage(String socketId) async {
|
||||
await const FlutterSecureStorage().write(key: 'socketId', value: socketId);
|
||||
await sl<SharedPreferences>().setString('socketId', socketId);
|
||||
}
|
||||
|
||||
static Future<void> removeSocketIdInStorage() async => (await const FlutterSecureStorage().delete(key: 'socketId'));
|
||||
static Future<void> removeSocketIdInStorage() async => (await sl<SharedPreferences>().remove('socketId'));
|
||||
}
|
||||
|
||||
45
pubspec.yaml
45
pubspec.yaml
@@ -13,11 +13,6 @@ dependencies:
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
flutter_secure_storage:
|
||||
git:
|
||||
url: https://github.com/sherlockvn/flutter_secure_storage.git
|
||||
ref: remove-old-encrypt-algorithm
|
||||
path: flutter_secure_storage
|
||||
flutter_bloc: ^9.1.1
|
||||
cached_network_image: ^3.4.1
|
||||
flutter_svg: ^2.2.0
|
||||
@@ -27,28 +22,28 @@ dependencies:
|
||||
validators: ^3.0.0
|
||||
path_provider: ^2.1.5
|
||||
carousel_slider_plus: ^7.1.1
|
||||
flutter_form_builder: ^10.1.0
|
||||
image_picker: ^1.1.2
|
||||
flutter_form_builder: ^10.2.0
|
||||
image_picker: ^1.2.0
|
||||
flutter_typeahead: ^5.2.0
|
||||
go_router: ^16.0.0
|
||||
go_router: ^16.1.0
|
||||
keyboard_dismisser: ^3.0.0
|
||||
retrofit: ^4.7.0
|
||||
get_it: ^8.1.0
|
||||
dio: ^5.8.0+1
|
||||
retrofit: ^4.7.1
|
||||
get_it: ^8.2.0
|
||||
dio: ^5.9.0
|
||||
dart_pusher_channels: ^1.2.3
|
||||
photo_view: ^0.15.0
|
||||
dismissible_page: ^1.0.2
|
||||
url_launcher: ^6.3.2
|
||||
easy_debounce: ^2.0.3
|
||||
badges: ^3.1.2
|
||||
google_fonts: ^6.2.1
|
||||
syncfusion_flutter_charts: ^30.1.42
|
||||
syncfusion_flutter_gauges: ^30.1.42
|
||||
google_fonts: ^6.3.0
|
||||
syncfusion_flutter_charts: ^30.2.5
|
||||
syncfusion_flutter_gauges: ^30.2.5
|
||||
table_calendar: ^3.2.0
|
||||
flutter_keyboard_visibility: ^6.0.0
|
||||
share_plus: ^11.0.0
|
||||
share_plus: ^11.1.0
|
||||
flutter_html: ^3.0.0
|
||||
file_picker: ^10.2.0
|
||||
file_picker: ^10.3.1
|
||||
audioplayers: ^6.5.0
|
||||
intl: ^0.20.2
|
||||
mask_text_input_formatter: ^2.9.0
|
||||
@@ -59,31 +54,31 @@ dependencies:
|
||||
flutter_image_compress: ^2.4.0
|
||||
image: ^4.5.4
|
||||
dotted_border: ^3.1.0
|
||||
http: ^1.4.0
|
||||
http: ^1.5.0
|
||||
flutter_native_splash: ^2.4.6
|
||||
webview_flutter: ^4.13.0
|
||||
sentry_flutter: ^9.5.0
|
||||
connectivity_plus: ^6.1.4
|
||||
sentry_flutter: ^9.6.0
|
||||
connectivity_plus: ^6.1.5
|
||||
visibility_detector: ^0.4.0+2
|
||||
firebase_core: ^3.15.2
|
||||
firebase_messaging: ^15.2.10
|
||||
firebase_core: ^4.0.0
|
||||
firebase_messaging: ^16.0.0
|
||||
http_parser: ^4.1.2
|
||||
path: ^1.9.1
|
||||
collection: ^1.19.1
|
||||
shared_preferences: ^2.5.3
|
||||
version: ^3.0.2
|
||||
package_info_plus: ^8.3.0
|
||||
package_info_plus: ^8.3.1
|
||||
device_info_plus: ^11.5.0
|
||||
permission_handler: ^12.0.1
|
||||
qr_code_scanner_plus: ^2.0.10+1
|
||||
flutter_dotenv: ^5.1.0
|
||||
flutter_dotenv: ^5.2.1
|
||||
uuid: ^4.5.1
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.6.0
|
||||
build_runner: ^2.7.0
|
||||
freezed: ^3.2.0
|
||||
json_serializable: ^6.10.0
|
||||
retrofit_generator: ^10.0.1
|
||||
retrofit_generator: ^10.0.2
|
||||
mockito: ^5.5.0
|
||||
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user