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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3c66af1f
Commit
3c66af1f
authored
Dec 01, 2021
by
Riccardo Padovani
Committed by
Sincheol (David) Kim
Dec 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `last_used_at` field to personal_access_token API
parent
5017e232
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
doc/api/personal_access_tokens.md
doc/api/personal_access_tokens.md
+4
-2
lib/api/entities/personal_access_token.rb
lib/api/entities/personal_access_token.rb
+1
-1
spec/lib/api/entities/personal_access_token_spec.rb
spec/lib/api/entities/personal_access_token_spec.rb
+26
-0
No files found.
doc/api/personal_access_tokens.md
View file @
3c66af1f
...
...
@@ -40,8 +40,9 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a
"scopes"
:
[
"api"
],
"active"
:
true
,
"user_id"
:
24
,
"last_used_at"
:
"2021-10-06T17:58:37.550Z"
,
"active"
:
true
,
"expires_at"
:
null
}
]
...
...
@@ -61,8 +62,9 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a
"scopes"
:
[
"api"
],
"active"
:
true
,
"user_id"
:
3
,
"last_used_at"
:
"2021-10-06T17:58:37.550Z"
,
"active"
:
true
,
"expires_at"
:
null
}
]
...
...
lib/api/entities/personal_access_token.rb
View file @
3c66af1f
...
...
@@ -3,7 +3,7 @@
module
API
module
Entities
class
PersonalAccessToken
<
Grape
::
Entity
expose
:id
,
:name
,
:revoked
,
:created_at
,
:scopes
,
:user_id
expose
:id
,
:name
,
:revoked
,
:created_at
,
:scopes
,
:user_id
,
:last_used_at
expose
:active?
,
as: :active
expose
:expires_at
do
|
personal_access_token
|
personal_access_token
.
expires_at
?
personal_access_token
.
expires_at
.
strftime
(
"%Y-%m-%d"
)
:
nil
...
...
spec/lib/api/entities/personal_access_token_spec.rb
0 → 100644
View file @
3c66af1f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
API
::
Entities
::
PersonalAccessToken
do
describe
'#as_json'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:token
)
{
create
(
:personal_access_token
,
user:
user
,
expires_at:
nil
)
}
let
(
:entity
)
{
described_class
.
new
(
token
)
}
it
'returns token data'
do
expect
(
entity
.
as_json
).
to
eq
({
id:
token
.
id
,
name:
token
.
name
,
revoked:
false
,
created_at:
token
.
created_at
,
scopes:
[
'api'
],
user_id:
user
.
id
,
last_used_at:
nil
,
active:
true
,
expires_at:
nil
})
end
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