diff --git a/lib/features/auth/data/auth_repository.dart b/lib/features/auth/data/auth_repository.dart index 2807f7d..193b2f6 100644 --- a/lib/features/auth/data/auth_repository.dart +++ b/lib/features/auth/data/auth_repository.dart @@ -38,11 +38,16 @@ class AuthRepository { Future> login({ required String email, required String password, + String? loginRole, }) async { try { final response = await _dio.post( ApiConstants.authLogin, - data: {'email': email, 'password': password}, + data: { + 'email': email, + 'password': password, + if (loginRole != null) 'loginRole': loginRole, + }, ); final data = response.data['data'] as Map; diff --git a/lib/features/auth/presentation/providers/auth_provider.dart b/lib/features/auth/presentation/providers/auth_provider.dart index fcdf364..28c5d8d 100644 --- a/lib/features/auth/presentation/providers/auth_provider.dart +++ b/lib/features/auth/presentation/providers/auth_provider.dart @@ -135,6 +135,7 @@ class AuthNotifier extends StateNotifier { Future login({ required String email, required String password, + String? loginRole, }) async { state = state.copyWith( status: AuthStatus.loading, @@ -146,6 +147,7 @@ class AuthNotifier extends StateNotifier { final result = await _repository.login( email: email, password: password, + loginRole: loginRole, ); if (result['requiresTwoFactor'] == true) { diff --git a/lib/features/auth/presentation/screens/login_screen.dart b/lib/features/auth/presentation/screens/login_screen.dart index 7ddafae..f65e6b5 100644 --- a/lib/features/auth/presentation/screens/login_screen.dart +++ b/lib/features/auth/presentation/screens/login_screen.dart @@ -53,6 +53,7 @@ class _LoginScreenState extends ConsumerState { ref.read(authProvider.notifier).login( email: _emailController.text.trim(), password: _passwordController.text, + loginRole: _selectedRole, ); } diff --git a/lib/features/auth/presentation/widgets/role_toggle.dart b/lib/features/auth/presentation/widgets/role_toggle.dart index d880057..af3fe86 100644 --- a/lib/features/auth/presentation/widgets/role_toggle.dart +++ b/lib/features/auth/presentation/widgets/role_toggle.dart @@ -23,7 +23,7 @@ class RoleToggle extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ _buildToggleButton('User', 'USER'), - _buildToggleButton('Admin', 'AGENT'), + _buildToggleButton('Agent', 'AGENT'), ], ), );