forked from eatvio/eatvio_app
fix: profile roles
This commit is contained in:
@@ -22,6 +22,7 @@ import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||
import 'package:eatvio_app/features/glossary/presentation/pages/glossary_screen.dart';
|
||||
import 'package:eatvio_app/features/menu/presentation/pages/menu_screen.dart';
|
||||
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
||||
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
||||
@@ -64,7 +65,17 @@ class AppRouter {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
builder: (context, state) => AuthScreen.builder(context),
|
||||
builder: (context, state) {
|
||||
final bool needLogout;
|
||||
if (state.extra == null) {
|
||||
needLogout = false;
|
||||
} else {
|
||||
needLogout = true;
|
||||
}
|
||||
return AuthScreen(
|
||||
needLogout: needLogout,
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'registration-screen',
|
||||
@@ -126,6 +137,11 @@ class AppRouter {
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/glossary-screen',
|
||||
name: '/glossaryScreen',
|
||||
builder: (context, state) => GlossaryScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/about-recipes-screen',
|
||||
name: 'aboutRecipesScreen',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// String baseUrl = 'https://eatvio.ru';
|
||||
String baseUrl = 'https://dev2.eatvio.com';
|
||||
String baseUrl = 'https://eatvio.ru';
|
||||
// String baseUrl = 'https://dev2.eatvio.com';
|
||||
|
||||
const List<int> durationValues = [7, 14, 21];
|
||||
|
||||
|
||||
32
lib/core/credentials_storage.dart
Normal file
32
lib/core/credentials_storage.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
abstract class CredentialsStorage {
|
||||
static Future<bool> haveCredentialsInStorage() async {
|
||||
try {
|
||||
if (await FlutterSecureStorage().read(key: 'email') == null || await FlutterSecureStorage().read(key: 'password') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, String>> getCredentialsFromStorage() async {
|
||||
return {
|
||||
'email': (await FlutterSecureStorage().read(key: 'email'))!,
|
||||
'password': (await FlutterSecureStorage().read(key: 'password'))!,
|
||||
};
|
||||
}
|
||||
|
||||
static saveCredentials(String email, String password) async {
|
||||
await FlutterSecureStorage().write(key: 'email', value: email);
|
||||
await FlutterSecureStorage().write(key: 'password', value: password);
|
||||
}
|
||||
|
||||
static removeCredentials() async {
|
||||
await FlutterSecureStorage().delete(key: 'email');
|
||||
await FlutterSecureStorage().delete(key: 'password');
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ 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 profilePlans;
|
||||
|
||||
@@ -155,4 +156,5 @@ Future<void> init() async {
|
||||
),
|
||||
),
|
||||
);
|
||||
sl.registerLazySingleton(() async => await FlutterSecureStorage());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ abstract class TokenStorage {
|
||||
sl<Dio>().options.headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
static haveTokenInStorage() async {
|
||||
static Future<bool> haveTokenInStorage() async {
|
||||
try {
|
||||
if (await FlutterSecureStorage().read(key: 'token') == null) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user