Skip to content
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

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft

Conversation

bjorngi
Copy link
Contributor

@bjorngi bjorngi commented Dec 13, 2024

No description provided.

@@ -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) => {
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +32 to +59
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')
})

Copy link
Contributor Author

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

Comment on lines +114 to +119
app.get('/internal/health/liveness', (_req: Request, res: Response) => {
res.sendStatus(200)
})

app.get('/internal/health/readiness', (_req: Request, res: Response) => {
res.sendStatus(200)
Copy link
Contributor Author

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

Comment on lines +144 to +163
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
}
}
)

Copy link
Contributor Author

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> = ({
Copy link
Contributor Author

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)

Comment on lines 210 to 215
} else if (
personData?.foedselsdato &&
isFoedtFoer1963(personData?.foedselsdato) &&
veilederBorgerFnr
) {
return <KalkulatorRedirect fnr={veilederBorgerFnr} />
Copy link
Contributor Author

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',
Copy link
Contributor Author

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

@@ -48,52 +40,6 @@ export const directAccessGuard = async () => {
}

// ////////////////////////////////////////
Copy link
Contributor Author

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) => {
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant