authcheck update v2

This commit is contained in:
2024-10-23 15:00:09 +02:00
parent 27b484ea6d
commit 750b323c80

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:patient_manager/mih_packages/authentication/signin_or_register.dart';
import 'package:patient_manager/mih_packages/mih_home/mih_profile_getter.dart';
@@ -12,17 +13,16 @@ class AuthCheck extends StatefulWidget {
}
class _AuthCheckState extends State<AuthCheck> {
late Future<bool> signedIn;
Future<bool> doesSessionExist() async {
//wait
await Future.delayed(const Duration(seconds: 1));
return await SuperTokens.doesSessionExist();
//await Future.delayed(const Duration(seconds: 1));
bool signedIn = await SuperTokens.doesSessionExist();
return signedIn;
}
@override
void initState() {
signedIn = doesSessionExist();
//signedIn = doesSessionExist();
super.initState();
}
@@ -33,12 +33,15 @@ class _AuthCheckState extends State<AuthCheck> {
builder: (BuildContext context, Orientation orientation) {
// Return a widget tree based on the orientation
return FutureBuilder(
future: signedIn,
future: doesSessionExist(),
builder: (context, snapshot) {
print(snapshot.data);
if (snapshot.data == true) {
return const MIHProfileGetter();
} else {
} else if (snapshot.data == false) {
return const SignInOrRegister();
} else {
return const Mihloadingcircle();
}
});
},