3
0
Fork 0
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:
Luke 2021-10-08 13:54:31 -05:00
parent f582640e8e
commit d5c9e8d73e

View file

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