Add log out to user settings page

This commit is contained in:
2024-05-30 11:02:08 +08:00
parent fb21e0cd73
commit 7f033570b3
5 changed files with 66 additions and 13 deletions

View File

@@ -332,10 +332,19 @@ void clearAllStates(BuildContext context) {
checkAuth(context);
}
void clearAllStates2(GoRouterState? state, GoRouter router) {
auth.clear();
tags.clear();
tasks.clear();
checkAuth2(state, router);
}
void checkAuth(BuildContext context) {
checkAuth2(GoRouterState.of(context), GoRouter.of(context));
}
void checkAuth2(GoRouterState? state, GoRouter router) {
if (!auth.isAuthed && !auth.checked && !auth.isChecking) {
final state = GoRouterState.of(context);
final router = GoRouter.of(context);
auth.checkAuth().then((re) {
if (!re) {
if (auth.status!.noUser &&
@@ -343,7 +352,7 @@ void checkAuth(BuildContext context) {
return;
}
final loc = auth.status!.noUser ? "/create_root_user" : "/login";
if (state.path != loc) {
if (state?.path != loc) {
router.push(loc);
}
}