From 0c64f5ae35d1a2d1a8cd0b16bda942e9fd619e3f Mon Sep 17 00:00:00 2001 From: Kajetan Kazimierczak Date: Wed, 13 Apr 2022 23:33:59 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Bara=20visa=20Freja=20om?= =?UTF-8?q?=20det=20finns=20tillg=C3=A4ngligt=20i=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/login.component.tsx | 35 ++++++++----------- libs/api-hjarntorget/lib/features.ts | 1 + libs/api-skolplattformen/lib/features.ts | 1 + libs/api/lib/features.ts | 6 ++-- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/apps/skolplattformen-app/components/login.component.tsx b/apps/skolplattformen-app/components/login.component.tsx index 793d5592e..025afdbbc 100644 --- a/apps/skolplattformen-app/components/login.component.tsx +++ b/apps/skolplattformen-app/components/login.component.tsx @@ -47,25 +47,11 @@ const BankId = () => ( const FrejaEid = () => ( ) - - -interface Logins { - BANKID_SAME_DEVICE: number - BANKID_ANOTHER_DEVICE: number - TEST_USER: number -} - -const LoginMethods: Logins = { - BANKID_SAME_DEVICE: 0, - BANKID_ANOTHER_DEVICE: 2, - TEST_USER: 3, -} - export const Login = () => { const { api } = useApi() const [cancelLoginRequest, setCancelLoginRequest] = useState< @@ -84,6 +70,7 @@ export const Login = () => { const loginBankIdSameDeviceWithoutId = useFeature( 'LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID' ) + const loginWithFrejaEnabled = useFeature('LOGIN_FREJA_EID') const { currentSchoolPlatform, changeSchoolPlatform } = useContext( SchoolPlatformContext ) @@ -95,10 +82,14 @@ export const Login = () => { const loginMethods = [ { id: 'thisdevice', title: t('auth.bankid.OpenOnThisDevice') }, { id: 'otherdevice', title: t('auth.bankid.OpenOnAnotherDevice') }, - { id: 'testuser', title: t('auth.loginAsTestUser') }, { id: 'freja', title: t('auth.freja.OpenOnThisDevice') }, + { id: 'testuser', title: t('auth.loginAsTestUser') }, ] as const + if (loginMethodId === 'freja' && !loginWithFrejaEnabled) { + setLoginMethodId('thisdevice') + } + const loginHandler = async () => { const user = await api.getUser() await AppStorage.clearPersonalData(user) @@ -112,10 +103,10 @@ export const Login = () => { } }, [api]) - const LoginProviderImage = () => { + const LoginProviderImage = () => { //if(loginMethodId == 'testuser') return undefined - if(loginMethodId == 'freja') return FrejaEid() - return BankId() + if (loginMethodId == 'freja') return FrejaEid() + return BankId() } const getSchoolPlatformName = () => { @@ -292,7 +283,11 @@ export const Login = () => { {t('auth.chooseLoginMethod')} f.id != 'freja') + } ItemSeparatorComponent={Divider} renderItem={({ item, index }) => (