@@ -3,7 +3,6 @@ import PT from 'prop-types';
33import _ from 'lodash' ;
44import { config } from 'topcoder-react-utils' ;
55import QRCode from 'react-qr-code' ;
6- import { UserManager } from 'oidc-client' ;
76import { SettingBannerV2 as Collapse } from 'components/Settings/SettingsBanner' ;
87import MfaImage from 'assets/images/account/security/mfa.svg' ;
98import DiceLogo from 'assets/images/account/security/dicelogo.png' ;
@@ -12,6 +11,7 @@ import GooglePlay from 'assets/images/account/security/google-play.svg';
1211import AppleStore from 'assets/images/account/security/apple-store.svg' ;
1312import UnsuccessfulIcon from 'assets/images/account/security/unsuccessful.svg' ;
1413import Modal from './Modal' ;
14+ import VerificationListener from './VerificationListener' ;
1515
1616
1717import './styles.scss' ;
@@ -23,6 +23,7 @@ export default function Security({
2323 const [ setupStep , setSetupStep ] = useState ( - 1 ) ;
2424 const [ isConnVerifyRunning , setIsConnVerifyRunning ] = useState ( false ) ;
2525 const [ connVerifyCounter , setConnVerifyCounter ] = useState ( 0 ) ;
26+ const diceVerifyUrl = config . DICE_VERIFY_URL ;
2627 const useInterval = ( callback , delay ) => {
2728 const savedCallback = useRef ( ) ;
2829
@@ -101,54 +102,23 @@ export default function Security({
101102 }
102103 } ;
103104
104- const verificationPopup = ( ) => {
105- const diceUrl = config . DICE_VERIFIER_URL ;
106- let baseRedirectUrl = config . URL . BASE ;
107- if ( baseRedirectUrl . indexOf ( '-dev' ) !== - 1 ) {
108- baseRedirectUrl = window . location . origin ;
109- }
110- const manager = new UserManager ( {
111- authority : diceUrl ,
112- client_id : 'topcoder' ,
113- response_type : 'code' ,
114- scope : 'openid profile vc_authn' ,
115- popup_redirect_uri : `${ baseRedirectUrl } /community-app-assets/dice-signin-callback.html` ,
116- response_mode : 'query' ,
117- loadUserInfo : false ,
118- popupWindowFeatures : 'location=no,toolbar=no,menubar=no,width=1000,height=611,left=100,top=100' ,
119- } ) ;
120- manager . settings . metadata = {
121- issuer : diceUrl ,
122- jwks_uri : `${ diceUrl } /.well-known/openid-configuration/jwks` ,
123- authorization_endpoint : `${ diceUrl } /vc/connect/authorize?pres_req_conf_id=Topcoder_2FA_Validate_Cred` ,
124- token_endpoint : `${ diceUrl } /vc/connect/token` ,
125- userinfo_endpoint : `${ diceUrl } /connect/userinfo` ,
126- check_session_iframe : `${ diceUrl } /vc/connect/checksession` ,
127- revocation_endpoint : `${ diceUrl } /vc/connect/revocation` ,
128- } ;
129-
130- manager . signinPopup ( ) . then (
131- ( user ) => {
132- const userEmail = _ . get ( user , 'profile.Email' ) ;
133- if ( ! _ . isUndefined ( userEmail ) && _ . lowerCase ( userEmail ) === _ . lowerCase ( emailAddress ) ) {
134- updateUserDice ( userId , true , tokenV3 ) ;
135- setSetupStep ( 3 ) ;
136- } else {
137- setSetupStep ( 4 ) ;
138- }
139- } ,
140- ( ) => { setSetupStep ( 4 ) ; } ,
141- ) ;
142- } ;
143-
144105 const goToVerification = ( ) => {
145106 if ( ! getConnectionAccepted ( ) ) {
146107 return ;
147108 }
148109 setSetupStep ( 2 ) ;
149- verificationPopup ( ) ;
150110 } ;
151111
112+ const verificationCallback = ( data ) => {
113+ const userEmail = _ . get ( data , 'profile.Email' ) ;
114+ if ( ! _ . isUndefined ( userEmail ) && _ . lowerCase ( userEmail ) === _ . lowerCase ( emailAddress ) ) {
115+ updateUserDice ( userId , true , tokenV3 ) ;
116+ setSetupStep ( 3 ) ;
117+ } else {
118+ setSetupStep ( 4 ) ;
119+ }
120+ }
121+
152122 const finishSetup = ( ) => {
153123 getUser2fa ( userId , tokenV3 ) ;
154124 closeSetup ( ) ;
@@ -216,27 +186,19 @@ export default function Security({
216186 </ div >
217187 </ Modal > ,
218188 < Modal
219- onCancel = { closeSetup }
220- leftButtonName = "Cancel"
221- leftButtonClick = { closeSetup }
222- rightButtonName = "Finish"
223- rightButtonClick = { ( ) => { } }
224- rightButtonDisabled
189+ showTools = { false }
190+ onCancel = { ( ) => { } }
191+ leftButtonName = ""
192+ leftButtonClick = { ( ) => { } }
193+ rightButtonName = ""
194+ rightButtonClick = { ( ) => { } }
225195 >
226- < div styleName = "step-body" >
227- < div styleName = "step-title" >
228- Processing...
229- </ div >
230- < div styleName = "step-content" >
231- Please wait while your credentials are validated.
232- </ div >
233- < div styleName = "body-logo" >
234- < img src = { DiceLogoBig } alt = "diceid" />
235- </ div >
236- </ div >
237- < div styleName = "step-footer" >
238- Powered by DICE ID
239- </ div >
196+ < iframe src = { `${ diceVerifyUrl } /dice-verifier.html` } />
197+ < VerificationListener
198+ event = "message"
199+ callback = { verificationCallback }
200+ source = { `${ diceVerifyUrl } /dice-verify-callback.html` }
201+ />
240202 </ Modal > ,
241203 < Modal
242204 onCancel = { closeSetup }
0 commit comments