fix(admin-ui): prevent admin login failure when admin roles are removed#2689
fix(admin-ui): prevent admin login failure when admin roles are removed#2689
Conversation
…ed (#2685) Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
📝 WalkthroughWalkthroughThis PR adds support for graceful logout handling when users lack valid roles. It introduces a new translation key "no_valid_role_logout" across all supported languages (English, Spanish, French, Portuguese) and updates the AppAuthProvider component to display a toast notification with a 10-second countdown before redirecting to logout, replacing the previous alert behavior. Changes
Sequence DiagramsequenceDiagram
participant User
participant AppAuthProvider
participant OAuth as OAuth/Token Provider
participant Toast as GluuToast Notification
participant Timer as Delay Timer
participant Logout as Logout Endpoint
User->>AppAuthProvider: Initiate login
AppAuthProvider->>OAuth: Request user info & validate
OAuth-->>AppAuthProvider: Return user data
AppAuthProvider->>AppAuthProvider: Verify user roles
alt Invalid Role Detected
AppAuthProvider->>Toast: Display logout warning with countdown
Toast-->>User: Show notification (no_valid_role_logout message)
AppAuthProvider->>Timer: Start 10-second timer
Timer-->>AppAuthProvider: Timer elapsed
AppAuthProvider->>Logout: Redirect to logout endpoint
Logout-->>User: Logout & redirect to login
else Valid Role
AppAuthProvider-->>User: Grant access
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@admin-ui/app/locales/es/translation.json`:
- Line 1008: Replace the single "no_valid_role_logout" string with i18next
pluralized keys "no_valid_role_logout_one" and "no_valid_role_logout_other"
(preserving the Spanish text variants, e.g., "1 segundo" vs "{{count}}
segundos"), and update the consuming code that renders this message to call the
translator with count: LOGOUT_DELAY_SECONDS (not seconds: LOGOUT_DELAY_SECONDS)
so i18next selects the correct plural form; reference the translation key
"no_valid_role_logout" and the constant LOGOUT_DELAY_SECONDS when making these
changes.
In `@admin-ui/app/locales/fr/translation.json`:
- Around line 953-954: Split the "no_valid_role_logout" translation into plural
forms (no_valid_role_logout_one and no_valid_role_logout_other) mirroring the
existing sessionTimeout pattern (use singular "seconde" vs plural "secondes"),
and update the caller in AppAuthProvider (the code around the logout/countdown
logic in AppAuthProvider.tsx) to pass a numeric "count" prop instead of
"seconds" when invoking the i18n lookup so the pluralization system is used;
locate usages of the key "no_valid_role_logout" and replace them to use the new
plural-aware keys via the i18n count parameter.
In `@admin-ui/app/utils/AppAuthProvider.tsx`:
- Around line 248-254: The missing-role path should not force a logout redirect
or call endSession; update the toast display in AppAuthProvider so that the
toast.error call for t('messages.no_valid_role_logout', { seconds:
LOGOUT_DELAY_SECONDS }) does not set onClose to redirect to sessionEndpoint (or
otherwise trigger endSession) and instead simply informs the user (keep
autoClose if desired) so fallback/default access behavior can proceed; edit the
block containing redirect, sessionEndpoint, toast.error, LOGOUT_DELAY_SECONDS
and remove/disable the redirect/onClose behavior that forces logout.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: cd6500e4-b34c-454c-9573-eae362c8030d
📒 Files selected for processing (5)
admin-ui/app/locales/en/translation.jsonadmin-ui/app/locales/es/translation.jsonadmin-ui/app/locales/fr/translation.jsonadmin-ui/app/locales/pt/translation.jsonadmin-ui/app/utils/AppAuthProvider.tsx



fix(admin-ui): prevent admin login failure when admin roles are removed (#2685)
Summary
This PR fixes an issue where the admin user was unable to log in after the
jansAdminUIRoleor other roles were removed from the user profile.Issue
If roles such as
jansAdminUIRole,jansAdminRole, oruserRolewere removed from the admin user and the changes were saved, the user could no longer log in to the Admin UI, even after resetting the password.Fix
Result
🔗 Ticket
Closes: #2685
Summary by CodeRabbit
New Features
Documentation