Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ workflows:
branches:
only:
- dev
- justin_fixes
- talent_search_fixes
- PROD-4398_integrate-userflow-remove-sprig
- PROD-4406_new-dice

- deployQa:
context: org-global
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,9 @@
}
}
]
},
"volta": {
"node": "16.15.0",
"yarn": "1.22.19"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/apps/accounts/src/lib/assets/security/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ReactComponent as MFAImage } from './mfa.svg'
import { ReactComponent as AppleStore } from './apple-store.svg'
import { ReactComponent as UnSuccessfullDiceVerificationIcon } from './unsuccessful.svg'
import credentialImage from './credential.png'
import diceIdLogo from './dicelogo.png'
import diceIdLogoBig from './dicelogobig.png'
import diceIdLogoSmall from './dicelogosmall.png'
import googlePlay from './google-play.png'

export {
AppleStore,
credentialImage,
diceIdLogo,
diceIdLogoBig,
diceIdLogoSmall,
googlePlay,
MFAImage,
UnSuccessfullDiceVerificationIcon,
}
46 changes: 29 additions & 17 deletions src/apps/accounts/src/settings/tabs/account/security/Security.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react'
import { toast } from 'react-toastify'
import { KeyedMutator } from 'swr'
import { noop } from 'lodash'

import { Button, Collapsible, FormToggleSwitch, IconSolid, Tooltip } from '~/libs/ui'
import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui'
import { diceIdLogo, MFAImage, SettingSection, triggerSurvey } from '~/apps/accounts/src/lib'
import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core'

Expand All @@ -23,10 +22,12 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
} = useMemberMFAStatus(props.profile.userId)

const [mfaEnabled, setMFAEnabled]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
const [diceEnabled, setDiceEnabled]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)

useEffect(() => {
if (mfaStatusData) {
setMFAEnabled(mfaStatusData.mfaEnabled)
setDiceEnabled(mfaStatusData.diceEnabled)
}
}, [mfaStatusData])

Expand All @@ -36,8 +37,9 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
mfaEnabled: !mfaEnabled,
},
})
.then(() => {
setMFAEnabled(!mfaEnabled)
.then(response => {
setMFAEnabled(response.result.content.mfaEnabled)
setDiceEnabled(response.result.content.diceEnabled)
toast.success('Your Multi Factor Authentication (MFA) status was updated.')
triggerSurvey()
})
Expand All @@ -46,6 +48,27 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
})
}

function handleUserDiceChange(): void {
if (!diceEnabled) {
return
}

updateMemberMFAStatusAsync(props.profile.userId, {
param: {
diceEnabled: !diceEnabled,
},
})
.then(response => {
setMFAEnabled(response.result.content.mfaEnabled)
setDiceEnabled(response.result.content.diceEnabled)
toast.success('Your DICE credential was disabled.')
triggerSurvey()
})
.catch(() => {
toast.error('Something went wrong. Please try again later.')
})
}

function handleDiceModalStatus(): void {
setSetupDiceModalOpen(!setupDiceModalOpen)
}
Expand All @@ -70,7 +93,6 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
name='mfaStatus'
onChange={handleUserMFAChange}
value={mfaEnabled}
disabled={mfaStatusData?.diceEnabled}
/>
)}
/>
Expand All @@ -86,12 +108,11 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
actionElement={(
<div className={styles.diceBtnWrap}>
{
mfaStatusData?.diceEnabled ? (
diceEnabled ? (
<FormToggleSwitch
name='diceEnabled'
onChange={noop}
onChange={handleUserDiceChange}
value={mfaStatusData?.diceEnabled as boolean}
disabled={mfaStatusData?.diceEnabled}
/>
) : (
<Button
Expand All @@ -104,15 +125,6 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
/>
)
}
{
mfaStatusData?.diceEnabled && (
<Tooltip
content='Please reach out to support@topcoder.com for deactivating Dice ID.'
>
<IconSolid.InformationCircleIcon />
</Tooltip>
)
}
</div>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FC, useEffect } from 'react'

import { DiceConnectionStatus, useDiceIdConnection } from '~/libs/core'

interface ConnectionHandlerProps {
onChange: (newStatus: DiceConnectionStatus) => void;
userId: number;
}

export const ConnectionHandler: FC<ConnectionHandlerProps> = (
props: ConnectionHandlerProps,
) => {
const diceConnection: DiceConnectionStatus | undefined = useDiceIdConnection(props.userId)

useEffect(() => {
if (diceConnection) {
props.onChange(diceConnection)
}
}, [diceConnection, props])

return (
<></>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
margin: auto;
}

.credentialImage {
height: 280px;
width: 400px;
align-self: center;
}

.diceBigLogo {
margin: $sp-4 0;
}
Expand Down
Loading