mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-06 03:44:56 +08:00
This commit is contained in:
parent
507a50de78
commit
7265cf03d9
4 changed files with 1374 additions and 30 deletions
|
@ -7,9 +7,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Two Factor Authentication',
|
NAME = 'Two Factor Authentication',
|
||||||
VERSION = '2.12',
|
VERSION = '2.12.3',
|
||||||
RELEASE = '2022-02-16',
|
RELEASE = '2022-02-16',
|
||||||
REQUIRED = '2.12.0',
|
REQUIRED = '2.12.3',
|
||||||
CATEGORY = 'Login',
|
CATEGORY = 'Login',
|
||||||
DESCRIPTION = 'Provides support for TOTP 2FA';
|
DESCRIPTION = 'Provides support for TOTP 2FA';
|
||||||
|
|
||||||
|
@ -117,6 +117,15 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
$aResult = $this->getTwoFactorInfo($oAccount);
|
$aResult = $this->getTwoFactorInfo($oAccount);
|
||||||
unset($aResult['BackupCodes']);
|
unset($aResult['BackupCodes']);
|
||||||
|
|
||||||
|
$name = \rawurlencode($oAccount->Email());
|
||||||
|
// $issuer = \rawurlencode(\RainLoop\API::Config()->Get('webmail', 'title', 'SnappyMail'));
|
||||||
|
$QR = \SnappyMail\QRCode::getMinimumQRCode(
|
||||||
|
// "otpauth://totp/{$issuer}:{$name}?secret={$aResult['Secret']}&issuer={$issuer}",
|
||||||
|
"otpauth://totp/{$name}?secret={$aResult['Secret']}",
|
||||||
|
\SnappyMail\QRCode::ERROR_CORRECT_LEVEL_M
|
||||||
|
);
|
||||||
|
$aResult['QRCode'] = $QR->__toString();
|
||||||
|
|
||||||
return $this->jsonResponse(__FUNCTION__, $aResult);
|
return $this->jsonResponse(__FUNCTION__, $aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,8 @@ class TwoFactorAuthSettings
|
||||||
this.twoFactorTested = ko.observable(false);
|
this.twoFactorTested = ko.observable(false);
|
||||||
|
|
||||||
this.viewSecret = ko.observable('');
|
this.viewSecret = ko.observable('');
|
||||||
|
this.viewQRCode = ko.observable('');
|
||||||
this.viewBackupCodes = ko.observable('');
|
this.viewBackupCodes = ko.observable('');
|
||||||
this.viewUrlTitle = ko.observable('');
|
|
||||||
this.viewUrl = ko.observable('');
|
|
||||||
|
|
||||||
this.viewEnable_ = ko.observable(false);
|
this.viewEnable_ = ko.observable(false);
|
||||||
|
|
||||||
|
@ -102,9 +101,8 @@ class TwoFactorAuthSettings
|
||||||
|
|
||||||
hideSecret() {
|
hideSecret() {
|
||||||
this.viewSecret('');
|
this.viewSecret('');
|
||||||
|
this.viewQRCode('');
|
||||||
this.viewBackupCodes('');
|
this.viewBackupCodes('');
|
||||||
this.viewUrlTitle('');
|
|
||||||
this.viewUrl('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createTwoFactor() {
|
createTwoFactor() {
|
||||||
|
@ -121,10 +119,7 @@ class TwoFactorAuthSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTwoFactor() {
|
clearTwoFactor() {
|
||||||
this.viewSecret('');
|
this.hideSecret();
|
||||||
this.viewBackupCodes('');
|
|
||||||
this.viewUrlTitle('');
|
|
||||||
this.viewUrl('');
|
|
||||||
|
|
||||||
this.twoFactorTested(false);
|
this.twoFactorTested(false);
|
||||||
|
|
||||||
|
@ -134,11 +129,7 @@ class TwoFactorAuthSettings
|
||||||
|
|
||||||
onShow(bLock) {
|
onShow(bLock) {
|
||||||
this.lock(!!bLock);
|
this.lock(!!bLock);
|
||||||
|
this.hideSecret('');
|
||||||
this.viewSecret('');
|
|
||||||
this.viewBackupCodes('');
|
|
||||||
this.viewUrlTitle('');
|
|
||||||
this.viewUrl('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHide() {
|
onHide() {
|
||||||
|
@ -162,11 +153,7 @@ class TwoFactorAuthSettings
|
||||||
this.viewEnable_(false);
|
this.viewEnable_(false);
|
||||||
this.twoFactorStatus(false);
|
this.twoFactorStatus(false);
|
||||||
this.twoFactorTested(false);
|
this.twoFactorTested(false);
|
||||||
|
this.hideSecret('');
|
||||||
this.viewSecret('');
|
|
||||||
this.viewBackupCodes('');
|
|
||||||
this.viewUrlTitle('');
|
|
||||||
this.viewUrl('');
|
|
||||||
} else {
|
} else {
|
||||||
this.viewUser(pString(oData.Result.User));
|
this.viewUser(pString(oData.Result.User));
|
||||||
this.viewEnable_(!!oData.Result.Enable);
|
this.viewEnable_(!!oData.Result.Enable);
|
||||||
|
@ -174,10 +161,8 @@ class TwoFactorAuthSettings
|
||||||
this.twoFactorTested(!!oData.Result.Tested);
|
this.twoFactorTested(!!oData.Result.Tested);
|
||||||
|
|
||||||
this.viewSecret(pString(oData.Result.Secret));
|
this.viewSecret(pString(oData.Result.Secret));
|
||||||
|
this.viewQRCode(oData.Result.QRCode);
|
||||||
this.viewBackupCodes(pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
|
this.viewBackupCodes(pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
|
||||||
|
|
||||||
this.viewUrlTitle(pString(oData.Result.UrlTitle));
|
|
||||||
this.viewUrl(null/*qr.toDataURL({ level: 'M', size: 8, value: this.getQr() })*/);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,12 +171,10 @@ class TwoFactorAuthSettings
|
||||||
|
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.viewSecret('');
|
this.viewSecret('');
|
||||||
this.viewUrlTitle('');
|
this.viewQRCode('');
|
||||||
this.viewUrl('');
|
|
||||||
} else {
|
} else {
|
||||||
this.viewSecret(pString(data.Result.Secret));
|
this.viewSecret(pString(data.Result.Secret));
|
||||||
this.viewUrlTitle(pString(data.Result.UrlTitle));
|
this.viewQRCode(pString(data.Result.QRCode));
|
||||||
this.viewUrl(null/*qr.toDataURL({ level: 'M', size: 6, value: this.getQr() })*/);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,7 @@
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p class="muted width100-on-mobile" style="width: 550px" data-i18n="POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_DESC"></p>
|
<p class="muted width100-on-mobile" style="width: 550px" data-i18n="POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_DESC"></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<!-- ko if: '' !== viewUrl() -->
|
<pre data-bind="text: viewQRCode" style="line-height:1;letter-spacing:-1px"></pre>
|
||||||
<img style="margin-left: -7px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=" data-bind="attr: {'src': viewUrl}" />
|
|
||||||
<!-- /ko -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group" data-bind="visible: '' !== viewBackupCodes()">
|
<div class="control-group" data-bind="visible: '' !== viewBackupCodes()">
|
||||||
|
|
1354
snappymail/v/0.0.0/app/libraries/snappymail/qrcode.php
Normal file
1354
snappymail/v/0.0.0/app/libraries/snappymail/qrcode.php
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue