-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect av personer født før 1963 i BFF #1629
base: main
Are you sure you want to change the base?
Conversation
fbfe8c8
to
8ed509b
Compare
4e62e98
to
a3fbd74
Compare
@@ -174,11 +306,13 @@ app.get('/pensjon/kalkulator/veileder?*', (_req: Request, res: Response) => { | |||
} | |||
}) | |||
|
|||
app.get('*', (_req: Request, res: Response) => { | |||
app.get('*', redirect163Middleware, async (_req: Request, res: Response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sjekker redirect163Middleware
før man blir servert kalkulator
- host: pensjonskalkulator-unleash-api.nav.cloud.nais.io | ||
inbound: | ||
rules: | ||
- application: wonderwalled-idporten # only in dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tillater å kunne hente ut idporten token fra https://wonderwalled-idporten.intern.dev.nav.no/api/obo?aud=dev-gcp:pensjonskalkulator:pensjonskalkulator-frontend
const env = ensureEnv({ | ||
unleashUrl: 'UNLEASH_SERVER_API_URL', | ||
unleashToken: 'UNLEASH_SERVER_API_TOKEN', | ||
unleashEnv: 'UNLEASH_SERVER_API_ENV', | ||
detaljertKalkulatorUrl: 'DETALJERT_KALKULATOR_URL', | ||
}) | ||
|
||
export const isFoedtFoer1963 = (foedselsdato: string): boolean => { | ||
const LAST_DAY_1962 = new Date(1962, 11, 31) | ||
return ( | ||
isBefore(new Date(foedselsdato), LAST_DAY_1962) || | ||
isSameDay(new Date(foedselsdato), LAST_DAY_1962) | ||
) | ||
} | ||
|
||
const unleash = initialize({ | ||
url: `${env.unleashUrl}/api`, | ||
appName: 'pensjonskalkulator-frontend', | ||
environment: env.unleashEnv, | ||
customHeaders: { | ||
Authorization: env.unleashToken, | ||
}, | ||
}) | ||
|
||
unleash.on('synchronized', () => { | ||
logger.info('Unleash synchronized') | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setter opp unleash for BFF
app.get('/internal/health/liveness', (_req: Request, res: Response) => { | ||
res.sendStatus(200) | ||
}) | ||
|
||
app.get('/internal/health/readiness', (_req: Request, res: Response) => { | ||
res.sendStatus(200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flytter health endepunkter slik at de ikke spammer loggene
app.use( | ||
'/pensjon/kalkulator/redirect/detaljert-kalkulator', | ||
express.urlencoded({ extended: true }), | ||
async (req: Request, res: Response) => { | ||
if (AUTH_PROVIDER === 'idporten') { | ||
res.redirect(`${env.detaljertKalkulatorUrl}`) | ||
return | ||
} else if (AUTH_PROVIDER === 'azure') { | ||
const { fnr } = req.body | ||
const url = new URL(env.detaljertKalkulatorUrl) | ||
const loggedOnName = await getUsernameFromAzureToken(req) | ||
|
||
url.searchParams.append('_brukerId', fnr) | ||
url.searchParams.append('_loggedOnName', loggedOnName) | ||
res.redirect(url.toString()) | ||
return | ||
} | ||
} | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nytt endepunkt for å kunne redirigere til detaljert kalkulator (både del A og del B)
interface IKalkulatorRedirectProps { | ||
fnr: string | ||
} | ||
export const KalkulatorRedirect: React.FC<IKalkulatorRedirectProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Komponent for å redirigere med fnr
(trengs for å kunne sende til Del B)
} else if ( | ||
personData?.foedselsdato && | ||
isFoedtFoer1963(personData?.foedselsdato) && | ||
veilederBorgerFnr | ||
) { | ||
return <KalkulatorRedirect fnr={veilederBorgerFnr} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sende til Del B for veileder
@@ -5,8 +5,7 @@ export const externalUrls = { | |||
dinPensjonBeholdning: 'https://www.nav.no/pensjon/opptjening/nb/', | |||
dinPensjonEndreSoeknad: | |||
'https://www.nav.no/pensjon/selvbetjening/alderspensjon/endringssoknad', | |||
detaljertKalkulator: | |||
'https://www.nav.no/pselv/simulering.jsf?simpleMode=true', | |||
detaljertKalkulator: '/pensjon/kalkulator/redirect/detaljert-kalkulator', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bruk eget endepunkt i BFF for redirigering til detaljert kalkulator
src/router/loaders.tsx
Outdated
@@ -48,52 +40,6 @@ export const directAccessGuard = async () => { | |||
} | |||
|
|||
// //////////////////////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fjern bruk at feature toggle i kalkulator klient (gjøres i BFF)
@@ -0,0 +1,16 @@ | |||
export const ensureEnv = <T extends Record<string, string>>(variables: T) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stopper applikasjonen å starte dersom miljøvariabler mangler i BFF
No description provided.