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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
3ac840ff
Commit
3ac840ff
authored
Jul 18, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1100 from patthoyts/pt/ldap-no-email
Improve handling of misconfigured LDAP accounts.
parents
88033500
f322975c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+13
-0
app/models/user.rb
app/models/user.rb
+2
-1
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
3ac840ff
class
OmniauthCallbacksController
<
Devise
::
OmniauthCallbacksController
# Extend the standard message generation to accept our custom exception
def
failure_message
exception
=
env
[
"omniauth.error"
]
if
exception
.
class
==
OmniAuth
::
Error
error
=
exception
.
message
else
error
=
exception
.
error_reason
if
exception
.
respond_to?
(
:error_reason
)
error
||=
exception
.
error
if
exception
.
respond_to?
(
:error
)
error
||=
env
[
"omniauth.error.type"
].
to_s
end
error
.
to_s
.
humanize
if
error
end
def
ldap
# We only find ourselves here if the authentication to LDAP was successful.
...
...
app/models/user.rb
View file @
3ac840ff
...
...
@@ -80,7 +80,8 @@ class User < ActiveRecord::Base
def
self
.
find_for_ldap_auth
(
omniauth_info
)
name
=
omniauth_info
.
name
.
force_encoding
(
"utf-8"
)
email
=
omniauth_info
.
email
.
downcase
email
=
omniauth_info
.
email
.
downcase
unless
omniauth_info
.
email
.
nil?
raise
OmniAuth
::
Error
,
"LDAP accounts must provide an email address"
if
email
.
nil?
if
@user
=
User
.
find_by_email
(
email
)
@user
...
...
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