fixed login bug

This commit is contained in:
amirrezaghabeli
2025-08-21 10:59:28 +03:30
parent e5295e0eea
commit f81e9dd32d
4 changed files with 21 additions and 6 deletions
+4 -1
View File
@@ -41,7 +41,9 @@ List<SingleChildWidget> get apiClients {
create: (context) => TenderDetailService(networkManager: context.read()),
),
Provider(create: (context) => YourTendersService(networkManager: context.read())),
Provider(
create: (context) => YourTendersService(networkManager: context.read()),
),
Provider(
create: (context) => TendersService(networkManager: context.read()),
),
@@ -103,6 +105,7 @@ List<SingleChildWidget> get viewModels {
(context) => ProfileViewModel(
profileRepository: context.read(),
authRepository: context.read(),
authViewModel: context.read(),
),
),
];
+7 -1
View File
@@ -74,6 +74,12 @@ class AuthViewModel with ChangeNotifier {
notifyListeners();
}
Future<void> localLogout() async {
await _authRepository.localLogout();
_loggedInUser = null;
notifyListeners();
}
Future<void> logout() async {
_errorMessage = null;
notifyListeners();
@@ -82,7 +88,7 @@ class AuthViewModel with ChangeNotifier {
switch (result) {
case Ok<LogoutResponse>():
_loggedInUser = null;
localLogout();
break;
case Error<LogoutResponse>():
_errorMessage = result.error.toString();
+9 -3
View File
@@ -8,16 +8,20 @@ import '../core/utils/result.dart';
import '../data/repositories/profile_repository.dart';
import '../data/services/model/logout_response/logout_response.dart';
import '../data/services/model/profile_response/profile_response.dart';
import 'auth_view_model.dart';
class ProfileViewModel with ChangeNotifier {
final ProfileRepository _profileRepository;
final AuthRepository _authRepository;
final AuthViewModel _authViewModel;
ProfileViewModel({
required ProfileRepository profileRepository,
required AuthRepository authRepository,
required AuthViewModel authViewModel,
}) : _profileRepository = profileRepository,
_authRepository = authRepository {
_authRepository = authRepository,
_authViewModel = authViewModel {
getCompanyProfile();
}
@@ -81,7 +85,7 @@ class ProfileViewModel with ChangeNotifier {
notifyListeners();
}
Future<void> logout(BuildContext context) async {
Future<void> logout() async {
_errorMessage = null;
notifyListeners();
@@ -89,13 +93,15 @@ class ProfileViewModel with ChangeNotifier {
switch (result) {
case Ok<LogoutResponse>():
localLogout();
_authViewModel.localLogout();
_loggedOut = true;
break;
case Error<LogoutResponse>():
_errorMessage = result.error.toString();
break;
}
notifyListeners();
_errorMessage = null;
notifyListeners();
}
+1 -1
View File
@@ -135,7 +135,7 @@ class _MobileProfilePageState extends State<MobileProfilePage> {
SizedBox(height: 24.0.h()),
Spacer(),
InkWell(
onTap: () => viewModel.logout(context),
onTap: () => viewModel.logout(),
child: Container(
width: double.infinity,
height: 56.0.h(),