Skip to content

Commit

Permalink
fix: typo and set x-nhost-auth-elevated to the user id
Browse files Browse the repository at this point in the history
  • Loading branch information
onehassan committed Jan 24, 2024
1 parent 54c7bc4 commit 351607e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/routes/elevate/webauthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export const elevateWebauthnHandler: RequestHandler<
return sendError(res, 'user-not-found');
}

const { body } = req;
const { email } = body;
const { email } = req.body;

const user = await getUserByEmail(email);

Expand Down Expand Up @@ -89,23 +88,23 @@ export const elevateWebauthnHandler: RequestHandler<
return res.send(options);
};

export type ElevnateVerifyWebAuthnRequestBody = {
export type ElevateVerifyWebAuthnRequestBody = {
credential: AuthenticationCredentialJSON;
email: string;
};

export type ElevateVerifyWebAuthnResponseBody = SignInResponse;

export const elevateVerifyWebauthnSchema =
Joi.object<ElevnateVerifyWebAuthnRequestBody>({
Joi.object<ElevateVerifyWebAuthnRequestBody>({
email: email.required(),
credential: Joi.object().required(),
}).meta({ className: 'ElevateVerifyWebauthnSchema' });

export const elevateVerifyWebauthnHandler: RequestHandler<
{},
ElevateVerifyWebAuthnResponseBody,
ElevnateVerifyWebAuthnRequestBody
ElevateVerifyWebAuthnRequestBody
> = async (req, res) => {
if (!ENV.AUTH_WEBAUTHN_ENABLED) {
return sendError(res, 'disabled-endpoint');
Expand Down Expand Up @@ -198,7 +197,7 @@ export const elevateVerifyWebauthnHandler: RequestHandler<
userId: user.id,
checkMFA: false,
extraClaims: {
[`x-nhost-auth-elevated`]: true,
[`x-nhost-auth-elevated`]: user.id,
},
});

Expand Down

0 comments on commit 351607e

Please sign in to comment.