Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ldap/user.rb')
-rw-r--r--lib/gitlab/ldap/user.rb71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb
deleted file mode 100644
index f7f3ba9ad7d..00000000000
--- a/lib/gitlab/ldap/user.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require 'gitlab/o_auth/user'
-
-# LDAP extension for User model
-#
-# * Find or create user from omniauth.auth data
-# * Links LDAP account with existing user
-# * Auth LDAP user with login and password
-#
-module Gitlab
- module LDAP
- class User < Gitlab::OAuth::User
- class << self
- def find_by_uid_and_provider(uid, provider)
- # LDAP distinguished name is case-insensitive
- identity = ::Identity.
- where(provider: provider).
- where('lower(extern_uid) = ?', uid.downcase).last
- identity && identity.user
- end
- end
-
- def initialize(auth_hash)
- super
- update_user_attributes
- end
-
- # instance methods
- def gl_user
- @gl_user ||= find_by_uid_and_provider || find_by_email || build_new_user
- end
-
- def find_by_uid_and_provider
- self.class.find_by_uid_and_provider(
- auth_hash.uid.downcase, auth_hash.provider)
- end
-
- def find_by_email
- ::User.find_by(email: auth_hash.email)
- end
-
- def update_user_attributes
- return unless persisted?
-
- gl_user.skip_reconfirmation!
- gl_user.email = auth_hash.email
-
- # Build new identity only if we dont have have same one
- gl_user.identities.find_or_initialize_by(provider: auth_hash.provider,
- extern_uid: auth_hash.uid)
-
- gl_user
- end
-
- def changed?
- gl_user.changed? || gl_user.identities.any?(&:changed?)
- end
-
- def block_after_signup?
- ldap_config.block_auto_created_users
- end
-
- def allowed?
- Gitlab::LDAP::Access.allowed?(gl_user)
- end
-
- def ldap_config
- Gitlab::LDAP::Config.new(auth_hash.provider)
- end
- end
- end
-end