-
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.
Rough in TOTP and Backup Code screens
These are still WIPs, but having some structure makes it easier to collaborate. See #30
- Loading branch information
Showing
5 changed files
with
197 additions
and
106 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
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,76 @@ | ||
// | ||
export default function TOTP( { userRecord } ) { | ||
const enabledProviders = Object.values( userRecord.record[ '2fa_enabled_providers' ] ); | ||
const backupCodesStatus = enabledProviders.includes( 'Two_Factor_Backup_Codes' ) && | ||
record[ '2fa_backup_codes_remaining' ] > 0 ? 'enabled' : 'disabled'; | ||
|
||
return ( | ||
<> | ||
{ 'disabled' === backupCodesStatus && <Setup /> } | ||
{ 'enabled' === backupCodesStatus && <Manage /> } | ||
</> | ||
); | ||
} | ||
|
||
// | ||
function Setup() { | ||
return ( | ||
<> | ||
<p> | ||
Backup codes let you access your account if your phone is lost, stolen, or if you run it through the washing machine and the bag of rice trick doesn't work. | ||
We ask that you print this list of ten unique, one-time-use backup codes and keep the list in a safe place. | ||
</p> | ||
|
||
<p> | ||
Backup codes let you access your account if your phone is lost or stolen, or even just accidentally run through the washing machine! | ||
|
||
</p> | ||
|
||
<code> | ||
backup codes | ||
</code> | ||
|
||
<p> | ||
red exclamation mark icon | ||
Without access to the app, your phone, or a backup code, you will lose access to your account. | ||
|
||
|
||
check box | ||
I have printed or saved these codes | ||
|
||
all finished primary button | ||
|
||
copy icon button | ||
print icon button | ||
download icon button | ||
</p> | ||
</> | ||
); | ||
} | ||
|
||
// | ||
function Manage() { | ||
//make this DRY with the setup screen - modularize Setup so that this can call indivitual components | ||
|
||
return ( | ||
<> | ||
Generate new backup codes button - on click populates area below with new codes | ||
|
||
<p> | ||
Backup codes let you access your account if your phone is lost or stolen, or even just accidentally run through the washing machine! | ||
</p> | ||
|
||
<p> | ||
red exclamation mark icon | ||
Backup codes have not been verified. | ||
</p> | ||
|
||
<p> | ||
Type a Backup Code to Verify | ||
input field with placeholder "e.g. 12345678" | ||
</p> | ||
|
||
Verify 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,75 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
|
||
// | ||
export default function TOTP( { userRecord } ) { | ||
const enabledProviders = Object.values( userRecord.record[ '2fa_enabled_providers' ] ); | ||
const totpStatus = enabledProviders.includes( 'Two_Factor_Totp' ) ? 'enabled' : 'disabled'; | ||
|
||
return ( | ||
<> | ||
{ 'disabled' === totpStatus && <Setup /> } | ||
{ 'enabled' === totpStatus && <Manage /> } | ||
</> | ||
); | ||
} | ||
|
||
// | ||
function Setup() { | ||
// todo after setting this up is done, check if they have backup codes, and if not, redirect them to that screen | ||
|
||
return ( | ||
<> | ||
<p> | ||
Scan this QR code with the authenticator app on your mobile device. | ||
|
||
<a href=""> | ||
Can't scan the code? | ||
</a> | ||
</p> | ||
|
||
<p> | ||
qr image | ||
</p> | ||
|
||
<p> | ||
Then enter the six digit code provided by the app: | ||
</p> | ||
|
||
<p> | ||
input field w/ placeholder text | ||
</p> | ||
|
||
<p> | ||
Not sure what this screen means? You may need to download Authy or Google Authenticator for your phone | ||
{/* add links to those. maybe pick different ones> */ } | ||
</p> | ||
|
||
<p> | ||
<Button isPrimary> | ||
Enable | ||
</Button> | ||
|
||
<Button isSecondary> | ||
Cancel | ||
</Button> | ||
</p> | ||
</> | ||
); | ||
} | ||
|
||
// | ||
function Manage() { | ||
return ( | ||
<> | ||
You've enabled two-step authentication on your account — smart move! When you log in to WordPress.com, you'll need to enter your username and password, as well as a unique passcode generated by an app on your mobile device. | ||
|
||
Switching to a new device? Follow these steps to avoid losing access to your account. | ||
https://wordpress.com/support/security/two-step-authentication/#moving-to-a-new-device | ||
|
||
Status: Two-step authentication is currently on. | ||
</> | ||
); | ||
} |
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