mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
feat: add check to refreshApiKeyExpiryTime to not refresh long lived keys (#301)
This commit is contained in:
parent
9fc33181eb
commit
be5b6a8d49
1 changed files with 6 additions and 1 deletions
|
@ -90,10 +90,15 @@ export class ApiLogins extends BaseRepository {
|
||||||
const [loginId, token] = apiKey.split(".");
|
const [loginId, token] = apiKey.split(".");
|
||||||
if (!loginId || !token) return;
|
if (!loginId || !token) return;
|
||||||
|
|
||||||
|
const updatedTime = moment().utc().add(LOGIN_EXPIRY_TIME, "ms");
|
||||||
|
|
||||||
|
const login = await this.apiLogins.createQueryBuilder().where("id = :id", { id: loginId }).getOne();
|
||||||
|
if (!login || moment.utc(login.expires_at).isSameOrAfter(updatedTime)) 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: updatedTime.format(DBDateFormat),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue