-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor sync the auth feature with the backend and client update #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor sync the auth feature with the backend and client update #23
Conversation
This change updates the AuthenticationBloc to pass the 'isDashboardLogin: true' flag when calling the authentication repository. This aligns the dashboard with the updated HtAuthClient contract, which requires this flag to differentiate dashboard-specific login flows.
This change enhances the AuthenticationBloc by adding specific `catch` blocks for `UnauthorizedException`, `ForbiddenException`, and `NotFoundException`. This ensures that the UI can display precise error messages to the user during the dashboard-specific authentication flow, aligning with the updated `HtAuthClient` contract.
This refactors the AppBloc's user change handler to correctly evaluate dashboard access based on the user.roles list instead of a singular role property. The logic now checks for 'admin' or 'publisher' roles to grant authenticated status. It also corrects the condition for fetching user settings to depend on this authenticated status, not just the presence of a user object.
This refactors the AppBloc's user change handler to correctly evaluate dashboard access based on the user.roles list instead of a singular role property. The logic now checks for 'admin' or 'publisher' roles to grant authenticated status. It also corrects the condition for fetching user settings to depend on this authenticated status, not just the presence of a user object.
This refactors the AppBloc's user change handler to correctly evaluate dashboard access based on the user.roles list instead of a singular role property. The logic now checks for 'admin' or 'publisher' roles to grant authenticated status. It also corrects the condition for fetching user settings to depend on this authenticated status, not just the presence of a user object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly refactors the application's authentication and user role management system to synchronize with recent updates in the backend and client authentication libraries. It modifies how user authentication status is determined based on their roles, updates the type handling for user roles across various configuration forms, and enhances the sign-in process with dashboard-specific logic and more granular error handling.
Highlights
- Authentication Logic Refactor: The core application bloc (
AppBloc
) has been updated to determine user authentication status based on a user'sroles
(plural) array, specifically checking foradmin
orpublisher
roles, rather than a singlerole
property. This aligns with a new role management approach. - User Role Type Migration: Throughout the
AppConfigurationPage
and its sub-forms, theUserRole
enum has been replaced withUserRoles
(likely a class containing static string constants for roles), and theuserRole
parameter type has been updated fromUserRole
toString
. This change is reflected in how user preferences, ad configurations, and account actions are managed per role. - Enhanced Authentication Flow: The
AuthenticationBloc
now passes anisDashboardLogin: true
flag to the authentication repository'srequestSignInCode
andverifySignInCode
methods. New exception handling forUnauthorizedException
,ForbiddenException
, andNotFoundException
has been added to the sign-in process. - Dependency Updates: The
pubspec.lock
file has been updated to reflect newresolved-ref
hashes for severalht-auth-*
andht-shared
git repositories, indicating updates to underlying authentication and shared utility libraries.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the authentication and authorization logic to align with backend changes, primarily by switching from a single user role to a list of roles. The changes correctly update how authentication status is determined in AppBloc
and how role-based configurations are handled in the AppConfigurationPage
. The error handling in AuthenticationBloc
has also been improved with more specific exception types.
print('Error loading user app settings: ${e.message}'); | ||
emit(state.copyWith()); // Clear settings on error | ||
emit(state.copyWith(clearUserAppSettings: true)); | ||
} catch (e) { | ||
// Handle any other unexpected errors | ||
print('Unexpected error loading user app settings: $e'); | ||
emit(state.copyWith()); // Clear settings on error | ||
emit(state.copyWith(clearUserAppSettings: true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default: | ||
return const SizedBox.shrink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default: | ||
return const SizedBox.shrink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default: | ||
return const SizedBox.shrink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status
READY/IN DEVELOPMENT/HOLD
Description
Type of Change