From 9df499d198a84ecf705a836f19f193198458d3eb Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 6 Mar 2025 21:38:47 +0100 Subject: [PATCH] check token 100% --- covas_mobile/lib/pages/AddProfile.dart | 3 --- covas_mobile/lib/pages/EditProfile.dart | 5 +++++ covas_mobile/lib/pages/EditSettings.dart | 5 +++++ covas_mobile/lib/pages/ItemMenu.dart | 4 ++++ covas_mobile/lib/pages/ListItemByOrganizers.dart | 9 +++++++++ covas_mobile/lib/pages/ListItemByTags.dart | 9 +++++++++ covas_mobile/lib/pages/MapboxPages.dart | 5 +++++ covas_mobile/lib/pages/UpdateEventImage.dart | 4 ++++ 8 files changed, 41 insertions(+), 3 deletions(-) diff --git a/covas_mobile/lib/pages/AddProfile.dart b/covas_mobile/lib/pages/AddProfile.dart index 7e79277..5e7c8c0 100644 --- a/covas_mobile/lib/pages/AddProfile.dart +++ b/covas_mobile/lib/pages/AddProfile.dart @@ -13,7 +13,6 @@ import '../variable/globals.dart' as globals; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; -import '../classes/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -40,7 +39,6 @@ class AddProfile extends StatefulWidget { class _AddProfileState extends State with ShowAlertDialog { BannerAd? _bannerAd; - final AuthService _authService = AuthService(); TextEditingController inputUserName = TextEditingController(); @@ -142,7 +140,6 @@ class _AddProfileState extends State with ShowAlertDialog { @override void initState() { super.initState(); - _authService.checkTokenStatus(context); AdHelper.createBannerAd(() => setState(() {})).then((ad) { setState(() { diff --git a/covas_mobile/lib/pages/EditProfile.dart b/covas_mobile/lib/pages/EditProfile.dart index 31bde9e..c1aaea3 100644 --- a/covas_mobile/lib/pages/EditProfile.dart +++ b/covas_mobile/lib/pages/EditProfile.dart @@ -17,6 +17,7 @@ import '../variable/globals.dart' as globals; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import '../classes/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -44,6 +45,8 @@ class EditProfile extends StatefulWidget { class _EditProfileState extends State with ShowAlertDialog, ShowEventDialog { BannerAd? _bannerAd; + final AuthService _authService = AuthService(); + TextEditingController inputUserName = TextEditingController(); TextEditingController inputName = TextEditingController(); @@ -198,6 +201,8 @@ class _EditProfileState extends State @override void initState() { super.initState(); + _authService.checkTokenStatus(context); + AdHelper.createBannerAd(() => setState(() {})).then((ad) { setState(() { _bannerAd = ad; diff --git a/covas_mobile/lib/pages/EditSettings.dart b/covas_mobile/lib/pages/EditSettings.dart index c79e6c2..0be4c14 100644 --- a/covas_mobile/lib/pages/EditSettings.dart +++ b/covas_mobile/lib/pages/EditSettings.dart @@ -12,6 +12,7 @@ import '../classes/eventAdded.dart'; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import '../classes/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -39,6 +40,8 @@ class EditSettings extends StatefulWidget { class _EditProfileState extends State with ShowAlertDialog, ShowEventDialog { BannerAd? _bannerAd; + final AuthService _authService = AuthService(); + TextEditingController inputUserName = TextEditingController(); int? kilometer; @@ -60,6 +63,8 @@ class _EditProfileState extends State @override void initState() { super.initState(); + _authService.checkTokenStatus(context); + AdHelper.createBannerAd(() => setState(() {})).then((ad) { setState(() { _bannerAd = ad; diff --git a/covas_mobile/lib/pages/ItemMenu.dart b/covas_mobile/lib/pages/ItemMenu.dart index db6ae9c..8b18d0a 100644 --- a/covas_mobile/lib/pages/ItemMenu.dart +++ b/covas_mobile/lib/pages/ItemMenu.dart @@ -23,6 +23,7 @@ import 'EditEvent.dart'; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import '../classes/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -75,6 +76,7 @@ class ItemMenu extends StatefulWidget { class _ItemMenuState extends State with ShowAlertDialog { BannerAd? _bannerAd; + final AuthService _authService = AuthService(); String listUser = ""; String eventName = ""; @@ -91,6 +93,8 @@ class _ItemMenuState extends State with ShowAlertDialog { @override void initState() { super.initState(); + _authService.checkTokenStatus(context); + AdHelper.createBannerAd(() => setState(() {})).then((ad) { setState(() { _bannerAd = ad; diff --git a/covas_mobile/lib/pages/ListItemByOrganizers.dart b/covas_mobile/lib/pages/ListItemByOrganizers.dart index 2d8b62d..3a89580 100644 --- a/covas_mobile/lib/pages/ListItemByOrganizers.dart +++ b/covas_mobile/lib/pages/ListItemByOrganizers.dart @@ -11,6 +11,7 @@ import 'package:intl/date_symbol_data_local.dart'; import '../variable/globals.dart' as globals; import '../classes/MyDrawer.dart'; +import '../classes/auth_service.dart'; // app starting point void main() { @@ -41,6 +42,8 @@ class ListItemOrganizers extends StatefulWidget { // homepage state class _MyHomePageState extends State { + final AuthService _authService = AuthService(); + // variable to call and store future list of posts // function to fetch data from api and return future list of posts @@ -60,6 +63,12 @@ class _MyHomePageState extends State { return body; } + @override + void initState() { + super.initState(); + _authService.checkTokenStatus(context); + } + // build function @override Widget build(BuildContext context) { diff --git a/covas_mobile/lib/pages/ListItemByTags.dart b/covas_mobile/lib/pages/ListItemByTags.dart index 353dea8..3866cc9 100644 --- a/covas_mobile/lib/pages/ListItemByTags.dart +++ b/covas_mobile/lib/pages/ListItemByTags.dart @@ -12,6 +12,7 @@ import 'package:intl/date_symbol_data_local.dart'; import '../variable/globals.dart' as globals; import '../classes/MyDrawer.dart'; +import '../classes/auth_service.dart'; // app starting point void main() { @@ -43,6 +44,8 @@ class ListItemTags extends StatefulWidget { class _MyHomePageState extends State { // variable to call and store future list of posts + final AuthService _authService = AuthService(); + // function to fetch data from api and return future list of posts static Future> getPosts(tags) async { SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -60,6 +63,12 @@ class _MyHomePageState extends State { return body; } + @override + void initState() { + super.initState(); + _authService.checkTokenStatus(context); + } + // build function @override Widget build(BuildContext context) { diff --git a/covas_mobile/lib/pages/MapboxPages.dart b/covas_mobile/lib/pages/MapboxPages.dart index 686ddfa..8e005e9 100644 --- a/covas_mobile/lib/pages/MapboxPages.dart +++ b/covas_mobile/lib/pages/MapboxPages.dart @@ -11,6 +11,7 @@ import 'package:geolocator/geolocator.dart'; // For getting the user's location import '../classes/alert.dart'; // Assuming this contains your error dialog code. import '../variable/globals.dart' as globals; import '../classes/MyDrawer.dart'; +import '../classes/auth_service.dart'; void main() async { await dotenv.load(fileName: ".env"); // Load .env file @@ -44,6 +45,8 @@ class MapboxPages extends StatefulWidget { } class _MapboxPagesState extends State with ShowAlertDialog { + final AuthService _authService = AuthService(); + late MapboxMapController mapController; late String mapboxAccessToken; List routeCoordinates = []; @@ -58,6 +61,8 @@ class _MapboxPagesState extends State with ShowAlertDialog { @override void initState() { super.initState(); + _authService.checkTokenStatus(context); + _getUserLocation(); } diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 30823c5..2d46d2c 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -18,6 +18,7 @@ import '../variable/globals.dart' as globals; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import '../classes/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -51,6 +52,7 @@ class UpdateeventImage extends StatefulWidget { class _UpdateeventImageState extends State with ShowAlertDialog, ShowEventDialog { BannerAd? _bannerAd; + final AuthService _authService = AuthService(); TextEditingController inputName = TextEditingController(); @@ -316,6 +318,8 @@ class _UpdateeventImageState extends State @override void initState() { super.initState(); + _authService.checkTokenStatus(context); + AdHelper.createBannerAd(() => setState(() {})).then((ad) { setState(() { _bannerAd = ad;