3
0
Fork 0
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:
Luke 2022-04-21 14:47:06 -05:00 committed by GitHub
parent 9fc33181eb
commit be5b6a8d49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,10 +90,15 @@ export class ApiLogins extends BaseRepository {
const [loginId, token] = apiKey.split(".");
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(
{ id: loginId },
{
expires_at: moment().utc().add(LOGIN_EXPIRY_TIME, "ms").format(DBDateFormat),
expires_at: updatedTime.format(DBDateFormat),
},
);
}