check token 100%

This commit is contained in:
Valentin CZERYBA 2025-03-06 21:38:47 +01:00
parent e7afe8fddb
commit 9df499d198
8 changed files with 41 additions and 3 deletions

View File

@ -13,7 +13,6 @@ import '../variable/globals.dart' as globals;
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -40,7 +39,6 @@ class AddProfile extends StatefulWidget {
class _AddProfileState extends State<AddProfile> with ShowAlertDialog { class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
BannerAd? _bannerAd; BannerAd? _bannerAd;
final AuthService _authService = AuthService();
TextEditingController inputUserName = TextEditingController(); TextEditingController inputUserName = TextEditingController();
@ -142,7 +140,6 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
AdHelper.createBannerAd(() => setState(() {})).then((ad) { AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() { setState(() {

View File

@ -17,6 +17,7 @@ import '../variable/globals.dart' as globals;
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -44,6 +45,8 @@ class EditProfile extends StatefulWidget {
class _EditProfileState extends State<EditProfile> class _EditProfileState extends State<EditProfile>
with ShowAlertDialog, ShowEventDialog { with ShowAlertDialog, ShowEventDialog {
BannerAd? _bannerAd; BannerAd? _bannerAd;
final AuthService _authService = AuthService();
TextEditingController inputUserName = TextEditingController(); TextEditingController inputUserName = TextEditingController();
TextEditingController inputName = TextEditingController(); TextEditingController inputName = TextEditingController();
@ -198,6 +201,8 @@ class _EditProfileState extends State<EditProfile>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
AdHelper.createBannerAd(() => setState(() {})).then((ad) { AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() { setState(() {
_bannerAd = ad; _bannerAd = ad;

View File

@ -12,6 +12,7 @@ import '../classes/eventAdded.dart';
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -39,6 +40,8 @@ class EditSettings extends StatefulWidget {
class _EditProfileState extends State<EditSettings> class _EditProfileState extends State<EditSettings>
with ShowAlertDialog, ShowEventDialog { with ShowAlertDialog, ShowEventDialog {
BannerAd? _bannerAd; BannerAd? _bannerAd;
final AuthService _authService = AuthService();
TextEditingController inputUserName = TextEditingController(); TextEditingController inputUserName = TextEditingController();
int? kilometer; int? kilometer;
@ -60,6 +63,8 @@ class _EditProfileState extends State<EditSettings>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
AdHelper.createBannerAd(() => setState(() {})).then((ad) { AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() { setState(() {
_bannerAd = ad; _bannerAd = ad;

View File

@ -23,6 +23,7 @@ import 'EditEvent.dart';
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -75,6 +76,7 @@ class ItemMenu extends StatefulWidget {
class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog { class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
BannerAd? _bannerAd; BannerAd? _bannerAd;
final AuthService _authService = AuthService();
String listUser = ""; String listUser = "";
String eventName = ""; String eventName = "";
@ -91,6 +93,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
AdHelper.createBannerAd(() => setState(() {})).then((ad) { AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() { setState(() {
_bannerAd = ad; _bannerAd = ad;

View File

@ -11,6 +11,7 @@ import 'package:intl/date_symbol_data_local.dart';
import '../variable/globals.dart' as globals; import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart'; import '../classes/MyDrawer.dart';
import '../classes/auth_service.dart';
// app starting point // app starting point
void main() { void main() {
@ -41,6 +42,8 @@ class ListItemOrganizers extends StatefulWidget {
// homepage state // homepage state
class _MyHomePageState extends State<ListItemOrganizers> { class _MyHomePageState extends State<ListItemOrganizers> {
final AuthService _authService = AuthService();
// variable to call and store future list of posts // variable to call and store future list of posts
// function to fetch data from api and return future list of posts // function to fetch data from api and return future list of posts
@ -60,6 +63,12 @@ class _MyHomePageState extends State<ListItemOrganizers> {
return body; return body;
} }
@override
void initState() {
super.initState();
_authService.checkTokenStatus(context);
}
// build function // build function
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -12,6 +12,7 @@ import 'package:intl/date_symbol_data_local.dart';
import '../variable/globals.dart' as globals; import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart'; import '../classes/MyDrawer.dart';
import '../classes/auth_service.dart';
// app starting point // app starting point
void main() { void main() {
@ -43,6 +44,8 @@ class ListItemTags extends StatefulWidget {
class _MyHomePageState extends State<ListItemTags> { class _MyHomePageState extends State<ListItemTags> {
// variable to call and store future list of posts // 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 // function to fetch data from api and return future list of posts
static Future<List<Events>> getPosts(tags) async { static Future<List<Events>> getPosts(tags) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
@ -60,6 +63,12 @@ class _MyHomePageState extends State<ListItemTags> {
return body; return body;
} }
@override
void initState() {
super.initState();
_authService.checkTokenStatus(context);
}
// build function // build function
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -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 '../classes/alert.dart'; // Assuming this contains your error dialog code.
import '../variable/globals.dart' as globals; import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart'; import '../classes/MyDrawer.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
await dotenv.load(fileName: ".env"); // Load .env file await dotenv.load(fileName: ".env"); // Load .env file
@ -44,6 +45,8 @@ class MapboxPages extends StatefulWidget {
} }
class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog { class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
final AuthService _authService = AuthService();
late MapboxMapController mapController; late MapboxMapController mapController;
late String mapboxAccessToken; late String mapboxAccessToken;
List<LatLng> routeCoordinates = []; List<LatLng> routeCoordinates = [];
@ -58,6 +61,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
_getUserLocation(); _getUserLocation();
} }

View File

@ -18,6 +18,7 @@ import '../variable/globals.dart' as globals;
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -51,6 +52,7 @@ class UpdateeventImage extends StatefulWidget {
class _UpdateeventImageState extends State<UpdateeventImage> class _UpdateeventImageState extends State<UpdateeventImage>
with ShowAlertDialog, ShowEventDialog { with ShowAlertDialog, ShowEventDialog {
BannerAd? _bannerAd; BannerAd? _bannerAd;
final AuthService _authService = AuthService();
TextEditingController inputName = TextEditingController(); TextEditingController inputName = TextEditingController();
@ -316,6 +318,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_authService.checkTokenStatus(context);
AdHelper.createBannerAd(() => setState(() {})).then((ad) { AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() { setState(() {
_bannerAd = ad; _bannerAd = ad;