-
Notifications
You must be signed in to change notification settings - Fork 177
Label recommended methods to simplify the configuration #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+72
−23
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
57c26dd
List the recommended methods first
kasparsd fdf21f5
Style the recommended label
kasparsd c20681b
Use dotted to seperate from solid buttons and match the default abbr …
kasparsd b91faac
Per linter
kasparsd 2c4db5b
Help guide the user through setup
kasparsd bc4ed48
Translate the string
kasparsd e47f019
Escape the URL
kasparsd 2dd5bd8
Match WPCS
kasparsd 1fde89a
Describe the consequences
kasparsd caff650
Match the rest of the option helpers
kasparsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ public function register_rest_routes() { | |
| array( | ||
| 'methods' => WP_REST_Server::DELETABLE, | ||
| 'callback' => array( $this, 'rest_delete_totp' ), | ||
| 'permission_callback' => function( $request ) { | ||
| 'permission_callback' => function ( $request ) { | ||
| return Two_Factor_Core::rest_api_can_edit_user_and_update_two_factor_options( $request['user_id'] ); | ||
| }, | ||
| 'args' => array( | ||
|
|
@@ -77,20 +77,20 @@ public function register_rest_routes() { | |
| array( | ||
| 'methods' => WP_REST_Server::CREATABLE, | ||
| 'callback' => array( $this, 'rest_setup_totp' ), | ||
| 'permission_callback' => function( $request ) { | ||
| 'permission_callback' => function ( $request ) { | ||
| return Two_Factor_Core::rest_api_can_edit_user_and_update_two_factor_options( $request['user_id'] ); | ||
| }, | ||
| 'args' => array( | ||
| 'user_id' => array( | ||
| 'user_id' => array( | ||
| 'required' => true, | ||
| 'type' => 'integer', | ||
| ), | ||
| 'key' => array( | ||
| 'key' => array( | ||
| 'type' => 'string', | ||
| 'default' => '', | ||
| 'validate_callback' => null, // Note: validation handled in ::rest_setup_totp(). | ||
| ), | ||
| 'code' => array( | ||
| 'code' => array( | ||
| 'type' => 'string', | ||
| 'default' => '', | ||
| 'validate_callback' => null, // Note: validation handled in ::rest_setup_totp(). | ||
|
|
@@ -159,10 +159,10 @@ public function rest_delete_totp( $request ) { | |
| $this->user_two_factor_options( $user ); | ||
| $html = ob_get_clean(); | ||
|
|
||
| return [ | ||
| return array( | ||
| 'success' => true, | ||
| 'html' => $html, | ||
| ]; | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -198,10 +198,10 @@ public function rest_setup_totp( $request ) { | |
| $this->user_two_factor_options( $user ); | ||
| $html = ob_get_clean(); | ||
|
|
||
| return [ | ||
| return array( | ||
| 'success' => true, | ||
| 'html' => $html, | ||
| ]; | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -283,22 +283,19 @@ public function user_two_factor_options( $user ) { | |
| <div id="two-factor-totp-options"> | ||
| <?php | ||
| if ( empty( $key ) ) : | ||
|
|
||
| $key = $this->generate_key(); | ||
| $totp_url = $this->generate_qr_code_url( $user, $key ); | ||
|
|
||
| ?> | ||
|
|
||
| <p> | ||
| <?php esc_html_e( 'Please scan the QR code or manually enter the key, then enter an authentication code from your app in order to complete setup.', 'two-factor' ); ?> | ||
| <?php esc_html_e( 'Please scan the QR code or manually copy the shared secret key from below to your Authenticator app:', 'two-factor' ); ?> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message is now split into two -- one here above about the secret code and another closer to the code input box for clarity. |
||
| </p> | ||
| <p id="two-factor-qr-code"> | ||
| <a href="<?php echo $totp_url; ?>"> | ||
| Loading... | ||
| <a href="<?php echo esc_url( $totp_url ); ?>"> | ||
| <?php esc_html_e( 'Loading…', 'two-factor' ); ?> | ||
| <img src="<?php echo esc_url( admin_url( 'images/spinner.gif' ) ); ?>" alt="" /> | ||
| </a> | ||
| </p> | ||
|
|
||
| <style> | ||
| #two-factor-qr-code { | ||
| /* The size of the image will change based on the length of the URL inside it. */ | ||
|
|
@@ -343,7 +340,11 @@ public function user_two_factor_options( $user ) { | |
| </script> | ||
|
|
||
| <p> | ||
| <code><?php echo esc_html( $key ); ?></code> | ||
| <?php esc_html_e( 'Shared secret key:', 'two-factor' ); ?> <code><?php echo esc_html( $key ); ?></code> | ||
| </p> | ||
| <hr /> | ||
| <p> | ||
| <?php esc_html_e( 'Enter the code generated by the Authenticator app to complete the setup:', 'two-factor' ); ?> | ||
| </p> | ||
| <p> | ||
| <input type="hidden" id="two-factor-totp-key" name="two-factor-totp-key" value="<?php echo esc_attr( $key ); ?>" /> | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these flags as
<attr>elements that provide additional context inline on hover and for screen readers.