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

Fix several issues related to user management #406

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

gctucker
Copy link
Contributor

@gctucker gctucker commented Nov 10, 2023

This PR fixes several issues found when testing the new user management implementation:

  • api.user_manager: call UserManager parent with all arguments
    This is to avoid unexpected behaviour and fix hidden bugs.
  • api.main: rely on create_user_manager()
    This is to have only one way of creating the UserManager objects and simplify the code
  • api.user_manager: create EmailSender only when required
    This is to avoid requiring SMTP settings unless when actually trying to send an email
  • api.main: only look for duplicate user when required
    This is to remove unwanted checks for duplicate users when no new username is being provided

@gctucker gctucker force-pushed the user-manager-fixup branch 4 times, most recently from 7463936 to 539cd7c Compare November 15, 2023 12:51
@JenySadadia JenySadadia self-assigned this Nov 16, 2023
Convert self._email_sender to an attribute and only create the object
when required.  This way, the API can be run without email support as
long as no endpoints that rely on email features are used.

Signed-off-by: Guillaume Tucker <[email protected]>
Use create_user_manager() to get a UserManager object rather than
constructing it directly in the API handlers.  This removes
dependencies in api.main, avoids duplication and simplifies the
implementation.

Signed-off-by: Guillaume Tucker <[email protected]>
Rework the UserManager constructor to call the parent class with all
the arguments passed using the sandard idiom.  The arguments aren't
used in the constructor, so this makes it entirely generic, safer and
future-proof.

Signed-off-by: Guillaume Tucker <[email protected]>
Only look up if another user already exists if the update contains a
username and it's not already the same one as the initial user.

This avoids unnecessary errors when updating a user entry with the
same username and avoids database lookups with a username set to None.

Signed-off-by: Guillaume Tucker <[email protected]>
Copy link
Collaborator

@JenySadadia JenySadadia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@JenySadadia
Copy link
Collaborator

Tested OK locally.

@JenySadadia JenySadadia added this pull request to the merge queue Nov 16, 2023
Merged via the queue into kernelci:main with commit a84d46a Nov 16, 2023
4 checks passed
@gctucker gctucker deleted the user-manager-fixup branch November 16, 2023 22:14
@JenySadadia JenySadadia linked an issue Dec 7, 2023 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User account management
2 participants