Fix missing redirect after login
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2025-07-02 22:48:53 +02:00
parent ff97fb69f7
commit 7387e285a0
4 changed files with 17 additions and 7 deletions

View File

@ -1,10 +1,11 @@
import 'package:moneymgr_mobile/services/api/api_client.dart';
import 'package:moneymgr_mobile/services/api/api_token.dart';
import 'package:moneymgr_mobile/services/api/auth_api.dart';
import 'package:moneymgr_mobile/services/router/routes_list.dart';
import 'package:moneymgr_mobile/services/storage/secure_storage.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../services/router/routes_list.dart';
part 'auth_state.g.dart';
/// The current authentication state of the app.
@ -27,7 +28,7 @@ class CurrentAuthState extends _$CurrentAuthState {
await ApiClient(token: token).authInfo();
final secureStorage = ref.read(secureStorageProvider).requireValue;
secureStorage.setToken(token);
await secureStorage.setToken(token);
ref
// Invalidate the state so the auth state will be updated to authenticated.

View File

@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_gutter/flutter_gutter.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:moneymgr_mobile/providers/auth_state.dart';
import 'package:moneymgr_mobile/routes/login/base_auth_page.dart';
import 'package:moneymgr_mobile/services/api/api_token.dart';
import 'package:moneymgr_mobile/providers/auth_state.dart';
import 'package:moneymgr_mobile/services/router/routes_list.dart';
import 'package:moneymgr_mobile/utils/extensions.dart';
import 'package:moneymgr_mobile/widgets/app_button.dart';
@ -29,6 +31,11 @@ class ManualAuthScreen extends HookConsumerWidget {
tokenValue: tokenValueController.text,
),
);
if (context.mounted) {
if (context.canPop()) context.pop();
context.replace(profilePage);
}
} catch (e, s) {
Logger.root.severe("Failed to authenticate user! $e $s");
if (context.mounted) {
@ -51,8 +58,7 @@ class ManualAuthScreen extends HookConsumerWidget {
keyboardType: TextInputType.url,
decoration: const InputDecoration(
labelText: 'API URL',
helperText:
"Format: http://moneymgr.corp.com/api",
helperText: "Format: http://moneymgr.corp.com/api",
),
textInputAction: TextInputAction.next,
),

View File

@ -47,7 +47,7 @@ GoRouter router(Ref ref) {
],
),
NavigationItem(
path: '/profile',
path: profilePage,
body: (_) => const Text("Profile"),
icon: Icons.person_outline,
selectedIcon: Icons.person,

View File

@ -8,4 +8,7 @@ const authPage = "/login";
const manualAuthPage = "/login/manual";
/// Settings path
const settingsPage = "/settings";
const settingsPage = "/settings";
// Profile path
const profilePage = "/profile";