Skip to content

Commit

Permalink
Replace non-alphanumeric characters with dashes; Google Authenticator…
Browse files Browse the repository at this point in the history
… does not like spaces in the title
  • Loading branch information
peterjaap committed Mar 19, 2019
1 parent fcbc760 commit 892fe57
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Block/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public function __construct(
*/
public function getQrCodeBase64Image()
{
$imageData = base64_encode($this->googleAuthenticatorService->getQrCodeEndroid($this->storeManager->getWebsite()->getName() . ' 2FA Login', $this->_googleSecret));
// Replace non-alphanumeric characters with dashes; Google Authenticator does not like spaces in the title
$title = preg_replace('/[^a-z0-9]+/i', '-', $this->storeManager->getWebsite()->getName() . ' 2FA Login');
$imageData = base64_encode($this->googleAuthenticatorService->getQrCodeEndroid($title, $this->_googleSecret));
return 'data:image/png;base64,'.$imageData;
}

Expand Down

0 comments on commit 892fe57

Please sign in to comment.