Skip to content

Commit

Permalink
feat: 🎸 Bara visa Freja om det finns tillgängligt i api
Browse files Browse the repository at this point in the history
  • Loading branch information
kajetan-kazimierczak committed Apr 13, 2022
1 parent 170b4da commit 0c64f5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
35 changes: 15 additions & 20 deletions apps/skolplattformen-app/components/login.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,11 @@ const BankId = () => (
const FrejaEid = () => (
<Image
style={themedStyles.icon}
source={require('../assets/freja_eid_low.png')}
source={require('../assets/freja_eid_low.png')}
accessibilityIgnoresInvertColors
/>
)



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<
Expand All @@ -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
)
Expand All @@ -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)
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -292,7 +283,11 @@ export const Login = () => {
{t('auth.chooseLoginMethod')}
</Text>
<List
data={loginMethods}
data={
loginWithFrejaEnabled
? loginMethods
: loginMethods.filter((f) => f.id != 'freja')
}
ItemSeparatorComponent={Divider}
renderItem={({ item, index }) => (
<ListItem
Expand Down
1 change: 1 addition & 0 deletions libs/api-hjarntorget/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Features } from '@skolplattformen/api'

export const features: Features = {
LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: false,
LOGIN_FREJA_EID: false,
FOOD_MENU: false,
CLASS_LIST: false,
}
1 change: 1 addition & 0 deletions libs/api-skolplattformen/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Features } from '@skolplattformen/api'

export const features: Features = {
LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: true,
LOGIN_FREJA_EID: true,
FOOD_MENU: true,
CLASS_LIST: true,
}
6 changes: 4 additions & 2 deletions libs/api/lib/features.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export interface Features {
LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: boolean
LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: boolean,
LOGIN_FREJA_EID: boolean,
FOOD_MENU: boolean,
CLASS_LIST: boolean
CLASS_LIST: boolean,

}

export type FeatureType = keyof Features

0 comments on commit 0c64f5a

Please sign in to comment.