ft/adds auto refreshtoken to dashboard
This commit is contained in:
parent
496b81a5f5
commit
2b44a10858
@ -22,26 +22,16 @@ class StartPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _StartPageState extends State<StartPage> {
|
class _StartPageState extends State<StartPage> {
|
||||||
// List<BottomNavigationBarItem> _selectedBottomBarButtons = bottomBarButtons;
|
|
||||||
final List<BottomNavigationBarItem> bottombarButtons = [];
|
final List<BottomNavigationBarItem> bottombarButtons = [];
|
||||||
|
|
||||||
// void _init() async {
|
|
||||||
// final c = await GClient.client;
|
|
||||||
// setState(() {
|
|
||||||
// widget.client = c;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
void _updateClient(GClient c) {
|
void _updateClient(GClient c) {
|
||||||
setState(() {
|
setState(() {
|
||||||
print('GOT CLIENT: $c');
|
|
||||||
widget.client = c;
|
widget.client = c;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// _init();
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,21 +160,31 @@ class _StartPageState extends State<StartPage> {
|
|||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!widget.client.isLoggedIn) {
|
if (widget.client.session.accessTokenExpiresAt!
|
||||||
|
.toDateTime()
|
||||||
|
.isBefore(DateTime.now())) {
|
||||||
|
await widget.client.refreshToken();
|
||||||
|
}
|
||||||
|
if (!widget.client.isLoggedIn &&
|
||||||
|
context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text('Sitzung ist abgelaufen.'),
|
content: Text('Sitzung ist abgelaufen.'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
Navigator.pushAndRemoveUntil(
|
if (context.mounted) {
|
||||||
context,
|
Navigator.pushAndRemoveUntil(
|
||||||
MaterialPageRoute(
|
context,
|
||||||
builder: (context) =>
|
MaterialPageRoute(
|
||||||
LoginPage(client: widget.client)),
|
builder: (context) =>
|
||||||
(route) => false);
|
LoginPage(client: widget.client)),
|
||||||
|
(route) => false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
final ctx = context;
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
GClient c = await Navigator.push(
|
GClient c = await Navigator.push(
|
||||||
context,
|
ctx,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => DashboardPage(
|
builder: (context) => DashboardPage(
|
||||||
client: widget.client,
|
client: widget.client,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user