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
fc4bce75
Commit
fc4bce75
authored
Apr 22, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make fixes based on @vsizov's comments on MR !3749
parent
4076bce5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
7 deletions
+3
-7
app/controllers/profiles/personal_access_tokens_controller.rb
...controllers/profiles/personal_access_tokens_controller.rb
+0
-4
app/models/personal_access_token.rb
app/models/personal_access_token.rb
+2
-2
lib/api/helpers/authentication.rb
lib/api/helpers/authentication.rb
+1
-1
No files found.
app/controllers/profiles/personal_access_tokens_controller.rb
View file @
fc4bce75
...
...
@@ -2,10 +2,6 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
def
index
@active_personal_access_tokens
=
current_user
.
personal_access_tokens
.
active
.
order
(
:expires_at
)
@inactive_personal_access_tokens
=
current_user
.
personal_access_tokens
.
inactive
# Prefer this to `@user.personal_access_tokens.new`, because it
# litters the view's call to `@user.personal_access_tokens` with
# this stub personal access token.
@personal_access_token
=
PersonalAccessToken
.
new
(
user:
@user
)
end
...
...
app/models/personal_access_token.rb
View file @
fc4bce75
class
PersonalAccessToken
<
ActiveRecord
::
Base
belongs_to
:user
scope
:active
,
->
{
where
(
revoked:
false
).
where
(
"expires_at >=
:current OR expires_at IS NULL"
,
current:
Time
.
current
)
}
scope
:inactive
,
->
{
where
(
"revoked = true OR expires_at <
:current"
,
current:
Time
.
current
)
}
scope
:active
,
->
{
where
(
revoked:
false
).
where
(
"expires_at >=
NOW() OR expires_at IS NULL"
)
}
scope
:inactive
,
->
{
where
(
"revoked = true OR expires_at <
NOW()"
)
}
def
self
.
generate
(
params
)
personal_access_token
=
self
.
new
(
params
)
...
...
lib/api/helpers/authentication.rb
View file @
fc4bce75
...
...
@@ -42,7 +42,7 @@ module API
identifier
||=
params
[
SUDO_PARAM
]
||
env
[
SUDO_HEADER
]
# Regex for integers
if
!!
(
identifier
=~
/
^[0-9]+$
/
)
if
!!
(
identifier
=~
/
\A[0-9]+\z
/
)
identifier
.
to_i
else
identifier
...
...
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