-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip leftovers after db58453. reset and start on filling in TOTP. brea…
…k the nav header stuff into its own commit
- Loading branch information
Showing
4 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// todo probably delete this, just use straightforward approach like db584537ae1d919c552425c557c88360c65d8682. | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button, Flex, Notice, TextControl } from '@wordpress/components'; | ||
import { useCallback, useEffect, useState } from '@wordpress/element'; | ||
import { Icon, cancelCircleFilled, check, seen } from '@wordpress/icons'; | ||
// remove unused | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { SetupTOTP } from './setup-totp'; | ||
import { BackupCodes } from './backup-codes'; | ||
|
||
/** | ||
* Render the Password setting. | ||
*/ | ||
export default function SetupTwoFactor( { userRecord } ) { | ||
const [ step, setStep ] = useState( 'Introduction' ); | ||
|
||
// maybe move the steps etc up to a higher level like two-factor-setup.js | ||
// so that totp.js can just be focused on totp only | ||
|
||
const enableTOTPHandler = useCallback( () => { | ||
// save settings | ||
setStep( 'generateBackupCodes' ); | ||
} ); | ||
|
||
let renderFunction; | ||
|
||
switch ( step ) { | ||
case 'scanVerifyQrCode': | ||
renderFunction = <ScanVerifyQrCode onEnable={ enableTOTPHandler } />; | ||
break; | ||
|
||
case 'generateBackupCodes': | ||
renderFunction = <BackupCodes />; | ||
break; | ||
|
||
default: | ||
case 'Introduction': | ||
renderFunction = <Introduction onStart={ () => setStep( 'scanVerifyQrCode' ) } />; | ||
break; | ||
} | ||
|
||
return renderFunction; | ||
} | ||
|
||
|
||
// | ||
function Introduction( { onStart } ) { | ||
return ( | ||
<> | ||
<p> | ||
Two-Factor Authentication adds an extra layer of security to your account. | ||
Once enabled, logging in to WordPress.org will require you to enter a unique passcode | ||
generated by an app on your mobile device, in addition to your username and password. | ||
</p> | ||
|
||
<Button isPrimary onClick={ onStart }> | ||
Get Started | ||
</Button> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// todo probably delete this, just use straightforward approach like db584537ae1d919c552425c557c88360c65d8682. | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Card, CardBody, CardHeader } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { BackupCodes } from './backup-codes'; | ||
|
||
|
||
/** | ||
* Render the user's 2FA status. | ||
*/ | ||
export default function TwoFactorStatus( { userRecord } ) { | ||
const emailStatus = record.pending_email ? 'pending' : 'ok'; | ||
const totpStatus = Object.keys( record[ '2fa_enabled_providers' ] ).length ? 'enabled' : 'disabled'; | ||
const backupCodesStatus = record['2fa_backup_codes_remaining'] > 0 ? 'enabled' : 'disabled'; | ||
|
||
|
||
return( | ||
<> | ||
<Card> | ||
"You've enabled two-factor authenticaton on your account — smart move! ..." + | ||
"button to disable" | ||
</Card> | ||
|
||
<Card> | ||
backup codes | ||
genertate new backup codes button | ||
|
||
<BackupCodes /> | ||
</Card> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters