fixed login bug
This commit is contained in:
@@ -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(),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user