refactor: Update WebAuthn verification API to use initial values and remove unused endpoint

This commit is contained in:
Nawaz Dhandala
2025-09-30 13:38:20 +01:00
parent 43e344dfb1
commit 45b1dcbb7e
3 changed files with 3 additions and 29 deletions

View File

@@ -120,7 +120,7 @@ const LoginPage: () => JSX.Element = () => {
const verifyResult: HTTPResponse<JSONObject> = await API.post({
url: VERIFY_WEBAUTHN_AUTH_API_URL,
data: {
userId: data.userId,
...initialValues,
challenge: data.challenge,
credential: {
id: credential.id,

View File

@@ -18,8 +18,8 @@ export const GENERATE_WEBAUTHN_AUTH_OPTIONS_API_URL: URL = URL.fromURL(
).addRoute(new Route("/user-webauthn/generate-authentication-options"));
export const VERIFY_WEBAUTHN_AUTH_API_URL: URL = URL.fromURL(
APP_API_URL,
).addRoute(new Route("/user-webauthn/verify-authentication"));
IDENTITY_URL,
).addRoute(new Route("/verify-webauthn-auth"));
export const SERVICE_PROVIDER_LOGIN_URL: URL = URL.fromURL(
IDENTITY_URL,

View File

@@ -16,7 +16,6 @@ import Response from "../Utils/Response";
import { JSONObject } from "../../Types/JSON";
import CommonAPI from "./CommonAPI";
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
import User from "../../Models/DatabaseModels/User";
export default class UserWebAuthnAPI extends BaseAPI<
UserWebAuthn,
@@ -94,30 +93,5 @@ export default class UserWebAuthnAPI extends BaseAPI<
}
},
);
this.router.post(
`${new this.entityType().getCrudApiPath()?.toString()}/verify-authentication`,
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
try {
const data: JSONObject = req.body;
const userId: string = data["userId"] as string;
const challenge: string = data["challenge"] as string;
const credential: any = data["credential"];
const user: User = await UserWebAuthnService.verifyAuthentication({
userId: userId,
challenge: challenge,
credential: credential,
});
return Response.sendJsonObjectResponse(req, res, {
user: User.toJSON(user, User),
});
} catch (err) {
next(err);
}
},
);
}
}