TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322115

Change subject: Improve legibility of secret and tokens
......................................................................

Improve legibility of secret and tokens

- add space char seperators and create groups of 4 chars
- use monospace font
- increase the size of the codes slightly

Bug: T150907
Change-Id: Idb99f48b2d9eae6acacca80be61203ca6404782c
---
M OATHAuthKey.php
M modules/ext.oath.showqrcode.styles.css
M special/SpecialOATHEnable.php
3 files changed, 36 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OATHAuth 
refs/changes/15/322115/1

diff --git a/OATHAuthKey.php b/OATHAuthKey.php
index 0a4be15..95566b1 100644
--- a/OATHAuthKey.php
+++ b/OATHAuthKey.php
@@ -65,6 +65,13 @@
        }
 
        /**
+        * @return String
+        */
+       public function getSecretForDisplay() {
+               return $this->tokenFormatterFunction( $this->secret['secret'] );
+       }
+
+       /**
         * @return array
         */
        public function getScratchTokens() {
@@ -72,6 +79,27 @@
        }
 
        /**
+        * Retrieve current scratch tokens for display purposes
+        *
+        * The characters of the token are split in groups of 4
+        *
+        * @return array
+        */
+       public function getScratchTokensForDisplay() {
+               return array_map( [$this, 'tokenFormatterFunction'], 
$this->scratchTokens );
+       }
+
+       /**
+        * Formats a key or scratch token by creating groups of 4 seperated by 
space characters
+        * @param string $token Token to format
+        *
+        * @return string The token formatted for display
+        */
+       private function tokenFormatterFunction( $token ) {
+               return implode( ' ', str_split( $token, 4 ) );
+       }
+
+       /**
         * Verify a token against the secret or scratch tokens
         *
         * @param string $token Token to verify
diff --git a/modules/ext.oath.showqrcode.styles.css 
b/modules/ext.oath.showqrcode.styles.css
index 7d8f0e5..dbb01c4 100644
--- a/modules/ext.oath.showqrcode.styles.css
+++ b/modules/ext.oath.showqrcode.styles.css
@@ -1,3 +1,9 @@
 .client-nojs .mw-display-qrcode {
     display: none;
 }
+
+kbd {
+    font-family: monospace;
+    white-space: nowrap;
+    font-size: 120%;
+}
diff --git a/special/SpecialOATHEnable.php b/special/SpecialOATHEnable.php
index f37aafc..6fe3cb7 100644
--- a/special/SpecialOATHEnable.php
+++ b/special/SpecialOATHEnable.php
@@ -117,7 +117,7 @@
                                        '<strong>' . $this->msg( 
'oathauth-account' )->escaped() . '</strong><br/>'
                                        . $this->OATHUser->getAccount() . 
'<br/><br/>'
                                        . '<strong>' . $this->msg( 
'oathauth-secret' )->escaped() . '</strong><br/>'
-                                       . $key->getSecret() . '<br/>',
+                                       . '<kbd>' . $key->getSecretForDisplay() 
. '</kbd><br/>',
                                'raw' => true,
                                'section' => 'step2',
                        ],
@@ -180,7 +180,7 @@
        private function createResourceList( $resources ) {
                $resourceList = '';
                foreach ( $resources as $resource ) {
-                       $resourceList .= Html::rawElement( 'li', [], $resource 
);
+                       $resourceList .= Html::rawElement( 'li', [], 
HTML::rawElement( 'kbd', [], $resource ) );
                }
                return Html::rawElement( 'ul', [], $resourceList );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/322115
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb99f48b2d9eae6acacca80be61203ca6404782c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OATHAuth
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to