Files
amirrezaghabeli 38222afcfa Enhance authentication flow and user role management
- Updated AuthViewModel to hydrate user data from storage on initialization.
- Added method to AuthRepository for retrieving stored customer data.
- Enhanced AuthService to save and retrieve customer data from SharedPreferences.
- Refactored UI components to use context.watch for user role updates in MeetingTimeDialog, TenderDetailActions, and TendersPage.
- Improved navigation logic in final completion pages to handle user interactions more effectively.
2025-10-14 12:24:04 +03:30

60 lines
1.8 KiB
Dart

import 'package:tm_app/data/services/model/customer/customer.dart';
import 'package:tm_app/data/services/model/forgot_password_response/forgot_password_response_model.dart';
import 'package:tm_app/data/services/model/login_response/login_response_model.dart';
import 'package:tm_app/data/services/model/verify_otp_response/verify_otp_response_model.dart';
import '../../core/utils/result.dart';
import '../services/auth_service.dart';
import '../services/model/logout_response/logout_response.dart';
import '../services/model/reset_password_response/reset_password_response.dart';
class AuthRepository {
final AuthService _authService;
AuthRepository({required AuthService authService})
: _authService = authService;
Future<Result<LoginResponseModel>> login({
required String username,
required String password,
}) async {
return _authService.login(username: username, password: password);
}
Future<Result<LogoutResponse>> logout() async {
return _authService.logout();
}
Future<Result<ResetPasswordResponse>> resetPassword({
required String newPassword,
required String token,
}) async {
return _authService.resetPassword(newPassword: newPassword, token: token);
}
Future<void> localLogout() async {
return _authService.localLogout();
}
Future<Result<ForgotPasswordResponseModel>> forgotPassword({
required String email,
}) async {
return _authService.forgotPassword(email: email);
}
Future<Result<VerifyOtpResponseModel>> verifyOtp({
required String code,
required String email,
}) async {
return _authService.verifyOtp(code: code, email: email);
}
Future<Result<bool>> checkIsLoggedIn() async {
return _authService.checkIsLoggedIn();
}
Future<Customer?> getStoredCustomer() async {
return _authService.getStoredCustomer();
}
}