Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1187d3f2
Commit
1187d3f2
authored
Apr 04, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Synchronize user email with ldap.
parent
153705bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+1
-0
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+19
-0
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+4
-0
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
1187d3f2
...
...
@@ -24,6 +24,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
gitlab_ldap_access
do
|
access
|
if
access
.
allowed?
(
@user
)
access
.
update_permissions
(
@user
)
access
.
update_email
(
@user
)
sign_in_and_redirect
(
@user
)
else
flash
[
:alert
]
=
"Access denied for your LDAP account."
...
...
lib/gitlab/ldap/access.rb
View file @
1187d3f2
...
...
@@ -52,6 +52,25 @@ module Gitlab
end
end
# Update user email if it changed in LDAP
def
update_email
(
user
)
uid
=
user
.
extern_uid
ldap_user
=
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
uid
,
adapter
)
gitlab_user
=
::
User
.
where
(
provider:
'ldap'
,
extern_uid:
uid
).
last
if
gitlab_user
&&
ldap_user
&&
ldap_user
.
email
ldap_email
=
ldap_user
.
email
.
last
if
(
gitlab_user
.
email
!=
ldap_email
)
gitlab_user
.
update
(
email:
ldap_email
)
else
false
end
else
false
end
end
# Add user to GitLab group
# In case user already exists: update his access level
# only if existing permissions are lower than ldap one.
...
...
lib/gitlab/ldap/person.rb
View file @
1187d3f2
...
...
@@ -34,6 +34,10 @@ module Gitlab
uid
end
def
email
entry
.
try
(
:mail
)
end
def
dn
entry
.
dn
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment