mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix expired client secret logic
This commit is contained in:
@@ -331,9 +331,12 @@ export const loginMI = async (req: Request, res: Response) => {
|
|||||||
} = validatedClientSecretDatum;
|
} = validatedClientSecretDatum;
|
||||||
|
|
||||||
if (clientSecretTTL > 0) {
|
if (clientSecretTTL > 0) {
|
||||||
const expiresAt = new Date(new Date().getTime() + clientSecretTTL * 1000);
|
const clientSecretCreated = new Date(validatedClientSecretDatum.createdAt)
|
||||||
|
const ttlInMilliseconds = clientSecretTTL * 1000;
|
||||||
|
const currentDate = new Date();
|
||||||
|
const expirationTime = new Date(clientSecretCreated.getTime() + ttlInMilliseconds);
|
||||||
|
|
||||||
if (expiresAt < new Date()) {
|
if (currentDate > expirationTime) {
|
||||||
await MachineIdentityClientSecret.findByIdAndUpdate(
|
await MachineIdentityClientSecret.findByIdAndUpdate(
|
||||||
validatedClientSecretDatum._id,
|
validatedClientSecretDatum._id,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user