//native
type Clerk = {
apiKey: string;
};
/**
* Verify the password of a user
* Check that the user's password matches the supplied input.
Useful for custom auth flows and re-verification.
*/
export async function main(
auth: Clerk,
user_id: string,
body: { password: string },
) {
const url = new URL(
`https://api.clerk.com/v1/users/${user_id}/verify_password`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago