Backport LDAP user assignment changes from EE
See https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/146
This commit is contained in:
parent
ca171b8190
commit
1e666ce695
1 changed files with 8 additions and 7 deletions
|
@ -21,15 +21,16 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
# We only find ourselves here
|
# We only find ourselves here
|
||||||
# if the authentication to LDAP was successful.
|
# if the authentication to LDAP was successful.
|
||||||
def ldap
|
def ldap
|
||||||
@user = Gitlab::LDAP::User.new(oauth)
|
ldap_user = Gitlab::LDAP::User.new(oauth)
|
||||||
@user.save if @user.changed? # will also save new users
|
ldap_user.save if ldap_user.changed? # will also save new users
|
||||||
gl_user = @user.gl_user
|
|
||||||
gl_user.remember_me = params[:remember_me] if @user.persisted?
|
@user = ldap_user.gl_user
|
||||||
|
@user.remember_me = params[:remember_me] if ldap_user.persisted?
|
||||||
|
|
||||||
# Do additional LDAP checks for the user filter and EE features
|
# Do additional LDAP checks for the user filter and EE features
|
||||||
if @user.allowed?
|
if ldap_user.allowed?
|
||||||
log_audit_event(gl_user, with: :ldap)
|
log_audit_event(@user, with: :ldap)
|
||||||
sign_in_and_redirect(gl_user)
|
sign_in_and_redirect(@user)
|
||||||
else
|
else
|
||||||
flash[:alert] = "Access denied for your LDAP account."
|
flash[:alert] = "Access denied for your LDAP account."
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
|
|
Loading…
Reference in a new issue