mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 17:45:03 +00:00
Add check to refreshApiKeyExpiryTime to not refresh long lived keys
This commit is contained in:
parent
f582640e8e
commit
d5c9e8d73e
1 changed files with 12 additions and 1 deletions
|
@ -90,10 +90,21 @@ export class ApiLogins extends BaseRepository {
|
||||||
const [loginId, token] = apiKey.split(".");
|
const [loginId, token] = apiKey.split(".");
|
||||||
if (!loginId || !token) return;
|
if (!loginId || !token) return;
|
||||||
|
|
||||||
|
const updated_time = moment().utc().add(LOGIN_EXPIRY_TIME, "ms");
|
||||||
|
|
||||||
|
const login = await this.apiLogins
|
||||||
|
.createQueryBuilder()
|
||||||
|
.where("id = :id", { id: loginId })
|
||||||
|
.getOne();
|
||||||
|
|
||||||
|
if(!login) return;
|
||||||
|
|
||||||
|
if(moment.utc(login.expires_at).isSameOrAfter(updated_time)) return;
|
||||||
|
|
||||||
await this.apiLogins.update(
|
await this.apiLogins.update(
|
||||||
{ id: loginId },
|
{ id: loginId },
|
||||||
{
|
{
|
||||||
expires_at: moment().utc().add(LOGIN_EXPIRY_TIME, "ms").format(DBDateFormat),
|
expires_at: updated_time.format(DBDateFormat)
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue