in src/server/lib/okta/dangerouslySetPlaceholderPassword.ts [87:122]
export async function dangerouslySetPlaceholderPasswordUsingRecoveryToken({
id,
ip,
recoveryToken,
}: PlaceholderPasswordParamsWithRecoveryToken): Promise<string> {
// Validate the token
const { stateToken } = await validateRecoveryToken({
recoveryToken,
ip,
});
// Check if state token is defined
if (!stateToken) {
throw new OktaError({
message:
'dangerouslySetPlaceholderPassword failed: state token is undefined',
});
}
// Set the placeholder password as a cryptographically secure UUID
const placeholderPassword = crypto.randomUUID();
await resetPassword(
{
stateToken,
newPassword: placeholderPassword,
},
ip,
);
// Unset the emailValidated and passwordSetSecurely flags
await validateEmailAndPasswordSetSecurely({
id,
ip,
flagStatus: false,
});
return placeholderPassword;
}