mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 20:27:43 +00:00
return instance of ServiceTokenData instead of object
This commit is contained in:
@@ -150,8 +150,8 @@ export const getAuthSTDPayload = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [_, TOKEN_IDENTIFIER, TOKEN_SECRET] = <[string, string, string]>authTokenValue.split(".", 3);
|
const [_, TOKEN_IDENTIFIER, TOKEN_SECRET] = <[string, string, string]>authTokenValue.split(".", 3);
|
||||||
|
|
||||||
let serviceTokenData = await ServiceTokenData
|
const serviceTokenData = await ServiceTokenData
|
||||||
.findById(TOKEN_IDENTIFIER, "+secretHash +expiresAt").lean();
|
.findById(TOKEN_IDENTIFIER, "+secretHash +expiresAt")
|
||||||
|
|
||||||
if (!serviceTokenData) {
|
if (!serviceTokenData) {
|
||||||
throw ServiceTokenDataNotFoundError({ message: "Failed to find service token data" });
|
throw ServiceTokenDataNotFoundError({ message: "Failed to find service token data" });
|
||||||
@@ -168,7 +168,7 @@ export const getAuthSTDPayload = async ({
|
|||||||
message: "Failed to authenticate service token",
|
message: "Failed to authenticate service token",
|
||||||
});
|
});
|
||||||
|
|
||||||
serviceTokenData = await ServiceTokenData
|
const serviceTokenDataToReturn = await ServiceTokenData
|
||||||
.findOneAndUpdate({
|
.findOneAndUpdate({
|
||||||
_id: new Types.ObjectId(TOKEN_IDENTIFIER),
|
_id: new Types.ObjectId(TOKEN_IDENTIFIER),
|
||||||
}, {
|
}, {
|
||||||
@@ -176,11 +176,11 @@ export const getAuthSTDPayload = async ({
|
|||||||
}, {
|
}, {
|
||||||
new: true,
|
new: true,
|
||||||
})
|
})
|
||||||
.select("+encryptedKey +iv +tag").lean();
|
.select("+encryptedKey +iv +tag")
|
||||||
|
|
||||||
if (!serviceTokenData) throw ServiceTokenDataNotFoundError({ message: "Failed to find service token data" });
|
if (!serviceTokenDataToReturn) throw ServiceTokenDataNotFoundError({ message: "Failed to find service token data" });
|
||||||
|
|
||||||
return serviceTokenData;
|
return serviceTokenDataToReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user