feat: add role-based authentication support and update UI toggle label to Agent

This commit is contained in:
pradeepkumar
2026-04-13 20:26:10 +05:30
parent 9fbc0ba3d0
commit eb8a05dcc1
4 changed files with 10 additions and 2 deletions

View File

@@ -135,6 +135,7 @@ class AuthNotifier extends StateNotifier<AuthState> {
Future<void> login({
required String email,
required String password,
String? loginRole,
}) async {
state = state.copyWith(
status: AuthStatus.loading,
@@ -146,6 +147,7 @@ class AuthNotifier extends StateNotifier<AuthState> {
final result = await _repository.login(
email: email,
password: password,
loginRole: loginRole,
);
if (result['requiresTwoFactor'] == true) {

View File

@@ -53,6 +53,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
ref.read(authProvider.notifier).login(
email: _emailController.text.trim(),
password: _passwordController.text,
loginRole: _selectedRole,
);
}

View File

@@ -23,7 +23,7 @@ class RoleToggle extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
_buildToggleButton('User', 'USER'),
_buildToggleButton('Admin', 'AGENT'),
_buildToggleButton('Agent', 'AGENT'),
],
),
);