Fixed login bug after logout

This commit is contained in:
llsajjad
2025-08-18 17:02:28 +03:30
parent a4a4633fb0
commit 7e16198578
3 changed files with 38 additions and 17 deletions
+13 -2
View File
@@ -13,8 +13,8 @@ class AuthViewModel with ChangeNotifier {
: _authRepository = authRepository {
usernameController.addListener(_onTextChanged);
passwordController.addListener(_onTextChanged);
usernameFocus.addListener(_onTextChanged);
passwordFocus.addListener(_onTextChanged);
// usernameFocus.addListener(_onTextChanged);
// passwordFocus.addListener(_onTextChanged);
}
final TextEditingController usernameController = TextEditingController();
@@ -58,6 +58,10 @@ class AuthViewModel with ChangeNotifier {
switch (result) {
case Ok<LoginResponseModel>():
_loggedInUser = result.value.data.customer;
usernameController.text.trim();
passwordController.text.trim();
usernameController.clear();
passwordController.clear();
break;
case Error<LoginResponseModel>():
_errorMessage = result.error.toString();
@@ -70,6 +74,13 @@ class AuthViewModel with ChangeNotifier {
notifyListeners();
}
void forceLogout() {
_loggedInUser = null;
usernameController.clear();
passwordController.clear();
notifyListeners();
}
Future<void> logout() async {
_errorMessage = null;
notifyListeners();