Skip to content

Improvement to identity builder in LDAP::User

Ramya Authappan requested to merge github/fork/jamgregory/patch-1 into master

Created by: jamgregory

Currently, the find_or_initialize_by statement in the LDAP::User model will cause duplicate identities to be created when a new user logs in. This is because find_or_initialize_by can't check in-memory records, and a new identity is created by build_new_user in the OAuth::User model. By adding a persisted? check, find_or_initialize_by is ignored on the first run, and so duplicate identities aren't created.

This has only been a problem on our local installation of Gitlab because we block new LDAP accounts from logging in if they don't already exist (needs_blocking? is true if it's a new user). The duplicate identities wouldn't cause the user.save! statement to fail, but the user.block statement following it would fail.

Merge request reports

Loading