Skip to content

Commit

Permalink
Merge pull request #1505 from navikt/idporten-locale
Browse files Browse the repository at this point in the history
Setter parameter for locale til idporten ved innlogging
  • Loading branch information
anders-nom committed Nov 8, 2023
2 parents 53af940 + 5d2bd11 commit 2b6120d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/utils/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { erNavDekoratoren } from './Environment';
import { MenuValue } from './meny-storage-utils';
import { Environment } from '../store/reducers/environment-duck';
import { Locale } from 'store/reducers/language-duck';

type IdPortenLocale = 'nb' | 'nn' | 'en' | 'se';

const idPortenLocaleMap: Record<Locale, IdPortenLocale> = {
[Locale.BOKMAL]: 'nb',
[Locale.NYNORSK]: 'nn',
[Locale.SAMISK]: 'se',
[Locale.ENGELSK]: 'en',
[Locale.POLSK]: 'en',
[Locale.RUSSISK]: 'en',
[Locale.UKRAINSK]: 'en',
[Locale.IKKEBESTEMT]: 'nb',
};

const getRedirectUrlLogin = (environment: Environment, arbeidsflate: MenuValue) => {
const { MIN_SIDE_URL, MINSIDE_ARBEIDSGIVER_URL, PARAMS } = environment;
Expand Down Expand Up @@ -29,11 +43,12 @@ const getRedirectUrlLogin = (environment: Environment, arbeidsflate: MenuValue)

export const getLoginUrl = (environment: Environment, arbeidsflate: MenuValue, level?: string) => {
const { LOGIN_URL, PARAMS } = environment;
const { LEVEL } = PARAMS;
const { LEVEL, LANGUAGE } = PARAMS;

const redirectUrl = getRedirectUrlLogin(environment, arbeidsflate);
const idPortenLocale = idPortenLocaleMap[LANGUAGE];

return `${LOGIN_URL}?redirect=${redirectUrl}&level=${level || LEVEL}`;
return `${LOGIN_URL}?redirect=${redirectUrl}&level=${level || LEVEL}&locale=${idPortenLocale}`;
};

export const getLogOutUrl = (environment: Environment) => {
Expand Down

0 comments on commit 2b6120d

Please sign in to comment.