refactoring
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-22 02:20:03 -05:00
parent f8b1b8ad37
commit e4f59dadfb
3 changed files with 17 additions and 4 deletions

View File

@ -62,7 +62,7 @@ class _MyAppState extends State<MyApp> {
snackBarTheme: snackBarTheme,
),
title: constants.appTitle,
initialRoute: '/',
initialRoute: '/auth',
routes: {
'/':
(context) =>
@ -108,7 +108,14 @@ class AuthCheck extends StatelessWidget {
return Consumer<Auth>(
builder: (context, auth, __) {
if (!auth.authenticated) {
Navigator.of(context).pushReplacementNamed('/auth');
Future.delayed(Duration(milliseconds: 1), () {
if (constants.navigatorKey.currentContext == null) {
return;
}
Navigator.of(
constants.navigatorKey.currentContext!,
).pushNamedAndRemoveUntil('/auth', (Route<dynamic> route) => false);
});
return SizedBox.shrink();
}

View File

@ -9,7 +9,7 @@ import 'package:sodium_libs/sodium_libs.dart';
class Auth with ChangeNotifier {
bool _authenticated = false;
SecureKey _key = SecureKey.random(constants.sodium, 128);
SecureKey _key = SecureKey.random(constants.sodium, 32);
String _user = "";
bool get authenticated => _authenticated;
@ -53,6 +53,7 @@ class Auth with ChangeNotifier {
void logoff() {
_authenticated = false;
_user = "";
notifyListeners();
}
}

View File

@ -14,7 +14,11 @@ class MountList with ChangeNotifier {
final Auth _auth;
MountList(this._auth) {
_fetch();
_auth.addListener(() {
if (_auth.authenticated) {
_fetch();
}
});
}
List<Mount> _mountList = [];
@ -57,6 +61,7 @@ class MountList with ChangeNotifier {
);
if (response.statusCode == 401) {
displayAuthError();
_auth.logoff();
return;
}