clear mount list on login failure
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-22 09:50:24 -05:00
parent 6137b69bd3
commit 9fd5b7c03f
3 changed files with 10 additions and 3 deletions

View File

@ -5,12 +5,14 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:repertory/constants.dart' as constants; import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart'; import 'package:repertory/helpers.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:sodium_libs/sodium_libs.dart'; import 'package:sodium_libs/sodium_libs.dart';
class Auth with ChangeNotifier { class Auth with ChangeNotifier {
bool _authenticated = false; bool _authenticated = false;
SecureKey _key = SecureKey.random(constants.sodium, 32); SecureKey _key = SecureKey.random(constants.sodium, 32);
String _user = ""; String _user = "";
MountList? mountList;
bool get authenticated => _authenticated; bool get authenticated => _authenticated;
SecureKey get key => _key; SecureKey get key => _key;
@ -53,6 +55,7 @@ class Auth with ChangeNotifier {
void logoff() { void logoff() {
_authenticated = false; _authenticated = false;
_user = ""; _user = "";
mountList?.clear();
notifyListeners(); notifyListeners();
} }

View File

@ -14,6 +14,7 @@ class MountList with ChangeNotifier {
final Auth _auth; final Auth _auth;
MountList(this._auth) { MountList(this._auth) {
_auth.mountList = this;
_auth.addListener(() { _auth.addListener(() {
if (_auth.authenticated) { if (_auth.authenticated) {
_fetch(); _fetch();
@ -166,6 +167,11 @@ class MountList with ChangeNotifier {
return ret; return ret;
} }
void clear() {
_mountList = [];
notifyListeners();
}
Future<void> reset() async { Future<void> reset() async {
if (constants.navigatorKey.currentContext == null || if (constants.navigatorKey.currentContext == null ||
ModalRoute.of(constants.navigatorKey.currentContext!)?.settings.name != ModalRoute.of(constants.navigatorKey.currentContext!)?.settings.name !=
@ -178,8 +184,7 @@ class MountList with ChangeNotifier {
'Mount removed externally. Reloading...', 'Mount removed externally. Reloading...',
); );
_mountList = []; clear();
notifyListeners();
return _fetch(); return _fetch();
} }

View File

@ -2,7 +2,6 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/models/auth.dart'; import 'package:repertory/models/auth.dart';
import 'package:repertory/models/mount.dart'; import 'package:repertory/models/mount.dart';
import 'package:repertory/widgets/mount_settings.dart'; import 'package:repertory/widgets/mount_settings.dart';