summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
authorVincent Wong <wingyu64@gmail.com>2016-12-22 01:59:54 +1100
committerVincent Wong <wingyu64@gmail.com>2017-01-09 04:15:39 +1100
commitb6df93a51f90c7ed29ce6667c6b1a8debf02506e (patch)
treeff13ffc730ceeb52635bad3204db1050d0e74947 /lib/api/internal.rb
parentf264ec6ee74a0263b4e5212e921c4638c25f8fcd (diff)
downloadgitlab-ce-b6df93a51f90c7ed29ce6667c6b1a8debf02506e.tar.gz
Record and show last used date of SSH Keys
Addresses: Issue #13810 1. Adds a last_used_at attribute to the Key table/model 2. Update a key's last_used_at whenever it gets used 3. Display how long ago an ssh key was last used
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index db2d18f935d..d235977fbd8 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -28,6 +28,8 @@ module API
protocol = params[:protocol]
+ actor.update_last_used_at if actor.is_a?(Key)
+
access =
if wiki?
Gitlab::GitAccessWiki.new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities)
@@ -61,6 +63,8 @@ module API
status 200
key = Key.find(params[:key_id])
+ key.update_last_used_at
+
token_handler = Gitlab::LfsToken.new(key)
{
@@ -103,7 +107,9 @@ module API
key = Key.find_by(id: params[:key_id])
- unless key
+ if key
+ key.update_last_used_at
+ else
return { 'success' => false, 'message' => 'Could not find the given key' }
end