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
Kazuhiko Shiozaki
gitlab-ce
Commits
9028999c
Commit
9028999c
authored
Sep 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new OAuth classes
parent
0df1cf7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+15
-9
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
9028999c
...
...
@@ -18,33 +18,39 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def
ldap
# We only find ourselves here
# if the authentication to LDAP was successful.
@user
=
Gitlab
::
LDAP
::
User
.
find_or_create
(
request
.
env
[
"omniauth.auth"
]
)
@user
=
Gitlab
::
LDAP
::
User
.
find_or_create
(
oauth
)
@user
.
remember_me
=
true
if
@user
.
persisted?
sign_in_and_redirect
(
@user
)
end
private
def
handle_omniauth
oauth
=
request
.
env
[
'omniauth.auth'
]
provider
,
uid
=
oauth
[
'provider'
],
oauth
[
'uid'
]
if
current_user
# Change a logged-in user's authentication method:
current_user
.
extern_uid
=
uid
current_user
.
provider
=
provider
current_user
.
extern_uid
=
oauth
[
'uid'
]
current_user
.
provider
=
oauth
[
'provider'
]
current_user
.
save
redirect_to
profile_path
else
@user
=
User
.
find_or_new_for_omniauth
(
oauth
)
@user
=
Gitlab
::
OAuth
::
User
.
find
(
oauth
)
# Create user if does not exist
# and allow_single_sign_on is true
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
@user
||=
Gitlab
::
OAuth
::
User
.
create
(
oauth
)
end
if
@user
sign_in_and_redirect
@user
sign_in_and_redirect
(
@user
)
else
flash
[
:notice
]
=
"There's no such user!"
redirect_to
new_user_session_path
end
end
end
def
oauth
@oauth
||=
request
.
env
[
'omniauth.auth'
]
end
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