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
Tatuya Kamada
gitlab-ce
Commits
051324e1
Commit
051324e1
authored
Apr 19, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `authenticate_user_from_private_token!`
- No need to use `if`s when we have a `presence` check already.
parent
ade40fdc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
7 deletions
+1
-7
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-7
No files found.
app/controllers/application_controller.rb
View file @
051324e1
...
...
@@ -67,13 +67,7 @@ class ApplicationController < ActionController::Base
# From https://github.com/plataformatec/devise/wiki/How-To:-Simple-Token-Authentication-Example
# https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
def
authenticate_user_from_private_token!
user_token
=
if
params
[
:authenticity_token
].
presence
params
[
:authenticity_token
].
presence
elsif
params
[
:private_token
].
presence
params
[
:private_token
].
presence
elsif
request
.
headers
[
'PRIVATE-TOKEN'
].
present?
request
.
headers
[
'PRIVATE-TOKEN'
]
end
user_token
=
params
[
:authenticity_token
].
presence
||
params
[
:private_token
].
presence
||
request
.
headers
[
'PRIVATE-TOKEN'
].
presence
user
=
user_token
&&
User
.
find_by_authentication_token
(
user_token
.
to_s
)
if
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