BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
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