Commit 75b91b4f authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

circumvent login loop another way

parent 4e541456
......@@ -136,9 +136,14 @@ class _LoginPageState extends State<LoginPage> {
Navigator.of(context).pop();
if (api.user!.credentials!.scopes!.contains('admin')) {
Navigator.of(context).pushNamed('/admin');
} else {
} else if (api.user!.credentials!.scopes!.contains('user')) {
Navigator.of(context).pushNamed('/');
} else {
await File('$basePath/credentials').delete();
Navigator.of(context).pushNamed('/login');
}
} else {
await File('$basePath/credentials').delete();
}
}
......
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import '../api/auth_api.dart';
......@@ -23,9 +20,7 @@ class _AuthGuardState extends State<AuthGuard> {
if (_authApi!.user?.credentials?.expiration?.isAfter(DateTime.now()) ?? false) {
return widget.child;
} else {
Future.delayed(const Duration(milliseconds: 200)).then((value) async {
final basePath = (await getApplicationDocumentsDirectory()).path;
await File('$basePath/credentials').delete();
Future.delayed(const Duration(milliseconds: 200)).then((value) {
//Navigator.of(context).popUntil((route) => route.settings.name == '/');
Navigator.of(context).popAndPushNamed('/login');
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment