Check for UserConfig instance during user login #6668

Closed
opened 2025-12-29 19:43:41 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Jul 15, 2022).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

Check for the presence of a UserConfig instance after calling auth_login(). If a UserConfig instance does not exist for the user, create one.

Justification

When a new NetBox user is created, a UserConfig instance gets created automatically by the create_userconfig() receiver of the post_save signal. However, as discussed in #8718 (specifically this thread) there may be some scenarios where the automatic creation of a UserConfig does not occur for some unknown factor. (The example in question concerns a Docker deployment, but the condition could potentially arise in other cases, such as after an inadvertent deletion.)

Although it should not be strictly necessary, adding a sanity check to the login process should avoid an RelatedObjectDoesNotExist exception in such a scenario, and allow the user to log in and use NetBox successfully.

Originally created by @jeremystretch on GitHub (Jul 15, 2022). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes Check for the presence of a UserConfig instance after calling `auth_login()`. If a UserConfig instance does not exist for the user, create one. ### Justification When a new NetBox user is created, a UserConfig instance gets created automatically by the [`create_userconfig()`](https://github.com/netbox-community/netbox/blob/b9dd654e7ad35fe1b79feb15c92cb5276253fbbc/netbox/users/models.py#L176) receiver of the `post_save` signal. However, as discussed in #8718 (specifically [this thread](https://github.com/netbox-community/netbox/discussions/8718#discussioncomment-3155597)) there may be some scenarios where the automatic creation of a UserConfig does not occur for some unknown factor. (The example in question concerns a Docker deployment, but the condition could potentially arise in other cases, such as after an inadvertent deletion.) Although it should not be strictly necessary, adding a sanity check to the login process should avoid an `RelatedObjectDoesNotExist` exception in such a scenario, and allow the user to log in and use NetBox successfully.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 19:43:41 +01:00
adam closed this issue 2025-12-29 19:43:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6668