Skip to content
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 user registration and authentication process #26

Merged
merged 58 commits into from
Dec 5, 2023

Conversation

delano
Copy link
Contributor

@delano delano commented Dec 5, 2023

This pull request includes a significant rework of the user registration and authentication process. The changes made are as follows:

  • Consolidated the first_name and last_name fields into a single name field for simplifying user registration.

  • Removed unnecessary middleware declarations in settings to streamline the server response.

  • Handled user registration errors better in registration.py to provide more meaningful user feedback.

  • Altered the User class in user.py to allow null values in the username field, which will permit more flexibility in user registration.

  • Made the email field mandatory and unique in the user model to prevent multiple accounts with the same email.

  • Deleted old migration files and consolidated their changes in the first migration. This will make the project easier to maintain and more coherent.

  • Updated the user viewsets to reflect the user model changes and further optimize the registration process.

These changes aim to improve the user experience, streamline the registration process, and enhance error handling.

Signed-off-by: delano <[email protected]>
Signed-off-by: delano <[email protected]>
Includes new dependency drf-registration

Signed-off-by: delano <[email protected]>
And added logging

Signed-off-by: delano <[email protected]>
e.g. When registering with a duplicate email. Returns 400 but the
JSON error doesn't make it into the UI.

Signed-off-by: delano <[email protected]>
This revision significantly reworks the user registration and authentication process with the following changes:

- Consolidate `first_name` and `last_name` fields into a single `name` field for simplifying user registration.
- Remove unnecessary middleware declarations in settings to streamline the server response.
- Handle user registration errors better in `registration.py` to provide more meaningful user feedback.
- Alter class `User` in `user.py` to allow null values in `username`, which will permit more flexibility in user registration.
- Make the email field mandatory and unique in the user model to prevent multiple accounts with the same email.
- Delete old migration files and consolidate their changes in the first migration. This will make the project easier to maintain and more coherent.
- Update the user viewsets to reflect the user model changes and further optimize the registration process.

Signed-off-by: delano <[email protected]>
In the RegisterView.vue, we've added an immediate submission of form data when the user clicks the 'Next' button on the registration form. This introduces a significant UX improvement:

- Explicit axios import and addition of the `handleSubmit` function for asynchronously handling form data.
- Adjustment of form rules and some HTML attributes for compatibility with the new submission flow.
- Substitution of 'Next' function to the `handleSubmit` response to connect the enhanced flow.
- Inclusion of pre-emptive error handling, alerting users to issues like an occupied email address before they've completed the whole form.

This reduces the risk of a user filling out the entire form before discovering an error and prevents unnecessary repetition which can improve the user experience.

Signed-off-by: delano <[email protected]>
- Simplify the procedure to set an unusable password within register serializer creation method, enabling the creation of users without a password.
- Rename `registration.py` to `register.py` for consistency with the standard Django naming convention.
- Explicitly import status codes from rest_framework to increase code readability and maintain naming conventions.
- Refactor error handling in RegisterView's create method. Instead of returning an error response immediately, set a status code and error message on encountering an error, and return a response with error details at the end if there are any errors. This provides a more streamlined exception handling mechanism.
- Improve logging messages by including the user's email address along with the error message and stack trace, helping in easier debugging in the case of exceptions.
- Remove unnecessary commented out code, keeping the codebase clean and readable.

Signed-off-by: delano <[email protected]>
configuration file

Signed-off-by: delano <[email protected]>
Performed the following updates:
- Switched to using the standard DRF Registration serializer
instead of a custom one for user registration, streamlining code maintenance.
- Removed unused imports from the register
serializer file for cleaner code.
- Introduced a new API endpoint for checking if an email is unique.
- Standardized import statements and updated the API endpoint in 'vueform.config.ts' to comply
with established coding conventions.
- Created a public.py file, although the actual implementation is still commented out and is
yet to be completed.

Signed-off-by: delano <[email protected]>
Fix for registration flow `HyperlinkedIdentityField` error.

Signed-off-by: delano <[email protected]>
Signed-off-by: delano <[email protected]>
Update dependencies to latest versions

- Upgraded various packages to their newer versions, including vite plugins, postcss modules, vue related packages, and more.
- This ensures compatibility with recent changes and potential performance improvements.
- Dependencies such as `autoprefixer`, `postcss`, and `tailwindcss` are updated to maintain consistency with the latest CSS tools.
- Updated `axios` and `vue-i18n` for the latest features and fixes.
- `lilconfig` updated to match the latest schema formatting requirements.
- Removed deprecated version of `yaml` in favor of a single consistent version across the project.
- Adapted to the latest changes in the `webpack-bundle-analyzer` to accommodate recent options and API changes.

Signed-off-by: delano <[email protected]>
- Removed conditional displays for `FormErrors` and `FormMessages`
- Ensured both components are always rendered, simplifying the template structure
- Improves code readability and maintainability by removing unnecessary conditionals

Signed-off-by: delano <[email protected]>
* N.B. There is an issue with hot reloading. As in it's not
happening properly even though vite is noticing the changes.
Could be related to the dependency updates earlier today. Workaround:
hard stop and start the vite process for the time being.

- Enhanced the error response handler to clear existing messages before appending new ones.
- Modified the iteration over error response data to populate the message bag with key-value pairs, providing clearer feedback to the user.
- Disabled leftover debugger statements in success and error handlers.

Signed-off-by: delano <[email protected]>
- Updated router registration for UserViewSet to include a basename.
- Assigned names to existing admin and token auth paths for better URL name management.

This work is related to debugging the issues around `HyperlinkedIdentityField` coming from the register serializer.

Signed-off-by: delano <[email protected]>
- Changed 'Finish' to 'Register' on the form's finish button for better clarity.
- Cleared messageBag before handling responses to avoid message persistence.
- Added checks for non-response and server errors to improve error handling.
- Removed redundant code by clearing messageBag only once on error responses.

Signed-off-by: delano <[email protected]>
- Switched from `npm` to `yarn`, and updated commands for Vite usage, improving developer experience and build efficiency.
- Modified the `RegistrationVueform` component to display error messages and enabled the display of success messages for a better user interaction.
- Introduced a new `ref` for the form to better manage reactivity and state within the Vue component logic.
- Added a success message upon successful form submission to provide immediate feedback to users.
- Removed outdated comments and unused code fragments to clean up the codebase.

Signed-off-by: delano <[email protected]>
- Provided a workaround for markdown linting errors by inserting an ignore directive.
- This ensures the `yarn install` command in the README is displayed without triggering the MD014 rule from markdownlint.

Signed-off-by: delano <[email protected]>
- Added a new Vueform-based component structure within the `vvs/` directory, utilizing Vueform with Vite and Tailwind.
- Updated the `README.md` with instructions for setting up the new Vueform component and links to relevant documentation.
- Corrected duplicate `ref` attribute in `RegistrationVueform.vue` to prevent potential reference conflicts in the Vue component.

Signed-off-by: delano <[email protected]>
- Replaced `postcss-import` with type definitions (`@types/postcss-import`) for better dev support
- Ensured consistency in dev environment with updated lock file entries to reflect changes
- Improved type safety and tooling support for PostCSS-related development tasks

Signed-off-by: delano <[email protected]>
- Removed commented out password field and unused `ref` imports in `RegistrationVueform.vue`.
- Disabled the debugger in success and error handlers for a cleaner console output.
- Added a placeholder comment to implement a redirect after successful account creation.
- Ensured consistency by cleaning out the commented code and debugging statements.

Signed-off-by: delano <[email protected]>
@delano delano self-assigned this Dec 5, 2023
@delano delano added the feature A planned and/or designed feature in the pipeline label Dec 5, 2023
@delano delano merged commit 3232917 into main Dec 5, 2023
0 of 2 checks passed
@delano delano deleted the feature/20231121-client-onboarding branch December 5, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A planned and/or designed feature in the pipeline
Projects
Status: ✔️ Done
Development

Successfully merging this pull request may close these issues.

1 participant