Skip to content

Commit

Permalink
fix: check foundkey returns key
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jun 28, 2024
1 parent 614fa33 commit 828c247
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions services/api/src/routes/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ const keysRoute = async (
.where('key_fingerprint', fingerprint)
.toString(),
);
var date = new Date();
const convertDateFormat = R.init;
var lastUsed = convertDateFormat(date.toISOString());
await query(
sqlClientPool,
knex('ssh_key')
.where('id', foundkey[0].id)
.update({lastUsed: lastUsed})
.toString(),
);
// check if a key is found
if (foundkey.length > 0) {
var date = new Date();
const convertDateFormat = R.init;
var lastUsed = convertDateFormat(date.toISOString());
await query(
sqlClientPool,
knex('ssh_key')
.where('id', foundkey[0].id)
.update({lastUsed: lastUsed})
.toString(),
);
}

res.send(result);
};
Expand Down

0 comments on commit 828c247

Please sign in to comment.