mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
feat: dev and staging bypass
This commit is contained in:
@@ -25,6 +25,10 @@ import {
|
||||
type IdentitySubject,
|
||||
type IdentityVerificationState,
|
||||
} from "@/services/verifayda.service";
|
||||
import { isBypassEnv } from "@/utils/dev-bypass";
|
||||
|
||||
/** Sentinel code that skips the real eSignet exchange in dev/staging (see api's DEV_BYPASS_FAYDA_CODE). */
|
||||
const DEV_BYPASS_FAYDA_CODE = "DEV_BYPASS";
|
||||
|
||||
interface FaydaVerifyPanelProps {
|
||||
subject: IdentitySubject;
|
||||
@@ -80,6 +84,23 @@ export default function FaydaVerifyPanel({
|
||||
setError(null);
|
||||
setLoading(true);
|
||||
try {
|
||||
// Dev/staging only: send the tab straight to /fayda/callback with the
|
||||
// sentinel code instead of round-tripping through eSignet — that page's
|
||||
// existing completeIdentity()/navigate-back logic runs unchanged.
|
||||
if (isBypassEnv()) {
|
||||
stashPendingVerification({
|
||||
subject,
|
||||
returnTo:
|
||||
window.location.pathname +
|
||||
window.location.search +
|
||||
window.location.hash,
|
||||
});
|
||||
window.location.assign(
|
||||
`/fayda/callback?code=${DEV_BYPASS_FAYDA_CODE}&state=bypass`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const authorizationUrl = await verifaydaService.start();
|
||||
// Record who is being verified and where to come back to before the tab
|
||||
// leaves — /fayda/callback has no other way to know either.
|
||||
|
||||
4
apps/edr-freight-web/portal/src/utils/dev-bypass.ts
Normal file
4
apps/edr-freight-web/portal/src/utils/dev-bypass.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/** True when VITE_ENV is "dev" or "staging" — mirrors the API's ENV gate. */
|
||||
export function isBypassEnv(): boolean {
|
||||
return ["dev", "staging"].includes(import.meta.env.VITE_ENV ?? "");
|
||||
}
|
||||
@@ -23,6 +23,8 @@ interface ImportMetaEnv {
|
||||
readonly VITE_POSTHOG_KEY?: string;
|
||||
/** Self-hosted PostHog instance URL. */
|
||||
readonly VITE_POSTHOG_HOST?: string;
|
||||
/** "dev" | "staging" — enables the OTP/payment/Fayda bypass. Unset in prod. */
|
||||
readonly VITE_ENV?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
|
||||
Reference in New Issue
Block a user