mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-11-09 06:45:48 +08:00
Prepare more 2fa data
This commit is contained in:
parent
d9bab28bfe
commit
54d2fb93cc
2 changed files with 74 additions and 46 deletions
|
|
@ -9,7 +9,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
VERSION = '2.0',
|
VERSION = '2.0',
|
||||||
RELEASE = '2021-04-13',
|
RELEASE = '2021-04-13',
|
||||||
REQUIRED = '2.5.0',
|
REQUIRED = '2.5.0',
|
||||||
CATEGORY = 'Security',
|
CATEGORY = 'Login',
|
||||||
DESCRIPTION = 'This plugin allows you to to have TOTP';
|
DESCRIPTION = 'This plugin allows you to to have TOTP';
|
||||||
|
|
||||||
// \RainLoop\Notifications\
|
// \RainLoop\Notifications\
|
||||||
|
|
@ -29,13 +29,77 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
$this->UseLangs(true);
|
$this->UseLangs(true);
|
||||||
|
|
||||||
|
// $this->addCss('style.less');
|
||||||
$this->addJs('js/TwoFactorAuthSettings.js');
|
$this->addJs('js/TwoFactorAuthSettings.js');
|
||||||
|
/*
|
||||||
|
$this->addHook('api.bootstrap.plugins');
|
||||||
|
$this->addHook('event.imap-post-login');
|
||||||
|
$this->addHook('event.imap-pre-connect');
|
||||||
|
$this->addHook('event.imap-pre-login');
|
||||||
|
$this->addHook('event.login-post-login-provide');
|
||||||
|
$this->addHook('event.login-pre-login-provide');
|
||||||
|
$this->addHook('event.sieve-post-connect');
|
||||||
|
$this->addHook('event.sieve-post-login');
|
||||||
|
$this->addHook('event.sieve-pre-connect');
|
||||||
|
$this->addHook('event.sieve-pre-login');
|
||||||
|
$this->addHook('event.smtp-post-connect');
|
||||||
|
$this->addHook('event.smtp-post-login');
|
||||||
|
$this->addHook('event.smtp-pre-connect');
|
||||||
|
$this->addHook('event.smtp-pre-login');
|
||||||
|
$this->addHook('filter.acount');
|
||||||
|
$this->addHook('filter.action-params');
|
||||||
|
$this->addHook('filter.app-data');
|
||||||
|
$this->addHook('filter.application-config');
|
||||||
|
$this->addHook('filter.build-message');
|
||||||
|
$this->addHook('filter.build-read-receipt-message');
|
||||||
|
$this->addHook('filter.domain');
|
||||||
|
$this->addHook('filter.fabrica');
|
||||||
|
$this->addHook('filter.folders-before');
|
||||||
|
$this->addHook('filter.folders-complete');
|
||||||
|
$this->addHook('filter.folders-post');
|
||||||
|
$this->addHook('filter.folders-system-types');
|
||||||
|
$this->addHook('filter.http-paths');
|
||||||
|
$this->addHook('filter.http-query');
|
||||||
|
$this->addHook('filter.imap-credentials');
|
||||||
|
$this->addHook('filter.json-response');
|
||||||
|
$this->addHook('filter.login-credentials');
|
||||||
|
$this->addHook('filter.login-credentials.step-1');
|
||||||
|
$this->addHook('filter.login-credentials.step-2');
|
||||||
|
$this->addHook('filter.message-html'
|
||||||
|
$this->addHook('filter.message-plain');
|
||||||
|
$this->addHook('filter.message-rcpt');
|
||||||
|
$this->addHook('filter.read-receipt-message-plain');
|
||||||
|
$this->addHook('filter.result-message');
|
||||||
|
$this->addHook('filter.save-message');
|
||||||
|
$this->addHook('filter.send-message');
|
||||||
|
$this->addHook('filter.send-message-stream');
|
||||||
|
$this->addHook('filter.send-read-receipt-message');
|
||||||
|
$this->addHook('filter.sieve-credentials');
|
||||||
|
$this->addHook('filter.smtp-credentials');
|
||||||
|
$this->addHook('filter.smtp-from');
|
||||||
|
$this->addHook('filter.smtp-hidden-rcpt');
|
||||||
|
$this->addHook('filter.smtp-message-stream');
|
||||||
|
$this->addHook('filter.system-folders-names');
|
||||||
|
$this->addHook('filter.upload-response');
|
||||||
|
$this->addHook('json.action-post-call');
|
||||||
|
$this->addHook('json.action-pre-call');
|
||||||
|
$this->addHook('json.suggestions-input-parameters');
|
||||||
|
$this->addHook('json.suggestions-post');
|
||||||
|
$this->addHook('json.suggestions-pre');
|
||||||
|
$this->addHook('main.default-response');
|
||||||
|
$this->addHook('main.default-response-data');
|
||||||
|
$this->addHook('main.default-response-data');
|
||||||
|
$this->addHook('main.default-response-error-data');
|
||||||
|
$this->addHook('main.fabrica');
|
||||||
|
$this->addHook('service.app-delay-start-begin');
|
||||||
|
$this->addHook('service.app-delay-start-end');
|
||||||
|
*/
|
||||||
|
|
||||||
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
||||||
$this->addJsonHook('CreateTwoFactorSecret', 'DoCreateTwoFactorSecret');
|
$this->addJsonHook('CreateTwoFactorSecret', 'DoCreateTwoFactorSecret');
|
||||||
$this->addJsonHook('ShowTwoFactorSecret', 'DoShowTwoFactorSecret');
|
$this->addJsonHook('ShowTwoFactorSecret', 'DoShowTwoFactorSecret');
|
||||||
$this->addJsonHook('EnableTwoFactor', 'DoEnableTwoFactor');
|
$this->addJsonHook('EnableTwoFactor', 'DoEnableTwoFactor');
|
||||||
$this->addJsonHook('TestTwoFactorInfo', 'DoTestTwoFactorInfo');
|
$this->addJsonHook('VerifyTwoFactorCode', 'DoVerifyTwoFactorCode');
|
||||||
$this->addJsonHook('ClearTwoFactorInfo', 'DoClearTwoFactorInfo');
|
$this->addJsonHook('ClearTwoFactorInfo', 'DoClearTwoFactorInfo');
|
||||||
|
|
||||||
$this->addTemplate('templates/TwoFactorAuthSettings.html');
|
$this->addTemplate('templates/TwoFactorAuthSettings.html');
|
||||||
|
|
@ -54,7 +118,6 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function DoGetTwoFactorInfo() : array
|
public function DoGetTwoFactorInfo() : array
|
||||||
{
|
{
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
@ -155,7 +218,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return $this->DefaultResponse(__FUNCTION__, $bResult);
|
return $this->DefaultResponse(__FUNCTION__, $bResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DoTestTwoFactorInfo() : array
|
public function DoVerifyTwoFactorCode() : array
|
||||||
{
|
{
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,40 +13,12 @@ const
|
||||||
pString = value => null != value ? '' + value : '',
|
pString = value => null != value ? '' + value : '',
|
||||||
|
|
||||||
Remote = new class {
|
Remote = new class {
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
getTwoFactor(fCallback) {
|
|
||||||
rl.pluginRemoteRequest(fCallback, 'GetTwoFactorInfo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
createTwoFactor(fCallback) {
|
|
||||||
rl.pluginRemoteRequest(fCallback, 'CreateTwoFactorSecret');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
clearTwoFactor(fCallback) {
|
|
||||||
rl.pluginRemoteRequest(fCallback, 'ClearTwoFactorInfo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
showTwoFactorSecret(fCallback) {
|
|
||||||
rl.pluginRemoteRequest(fCallback, 'ShowTwoFactorSecret');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sCode
|
* @param {string} sCode
|
||||||
*/
|
*/
|
||||||
testTwoFactor(fCallback, sCode) {
|
verifyCode(fCallback, sCode) {
|
||||||
rl.pluginRemoteRequest(fCallback, 'TestTwoFactorInfo', {
|
rl.pluginRemoteRequest(fCallback, 'VerifyTwoFactorCode', {
|
||||||
Code: sCode
|
Code: sCode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -60,13 +32,6 @@ const
|
||||||
Enable: bEnable ? 1 : 0
|
Enable: bEnable ? 1 : 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
clearTwoFactorInfo(fCallback) {
|
|
||||||
rl.pluginRemoteRequest(fCallback, 'ClearTwoFactorInfo');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TwoFactorAuthSettings
|
class TwoFactorAuthSettings
|
||||||
|
|
@ -135,7 +100,7 @@ class TwoFactorAuthSettings
|
||||||
|
|
||||||
showSecret() {
|
showSecret() {
|
||||||
this.secreting(true);
|
this.secreting(true);
|
||||||
Remote.showTwoFactorSecret(this.onShowSecretResult);
|
rl.pluginRemoteRequest(this.onShowSecretResult, 'ShowTwoFactorSecret');
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSecret() {
|
hideSecret() {
|
||||||
|
|
@ -147,7 +112,7 @@ class TwoFactorAuthSettings
|
||||||
|
|
||||||
createTwoFactor() {
|
createTwoFactor() {
|
||||||
this.processing(true);
|
this.processing(true);
|
||||||
Remote.createTwoFactor(this.onResult);
|
rl.pluginRemoteRequest(this.onResult, 'CreateTwoFactorSecret');
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|
@ -167,7 +132,7 @@ class TwoFactorAuthSettings
|
||||||
this.twoFactorTested(false);
|
this.twoFactorTested(false);
|
||||||
|
|
||||||
this.clearing(true);
|
this.clearing(true);
|
||||||
Remote.clearTwoFactor(this.onResult);
|
rl.pluginRemoteRequest(this.onResult, 'ClearTwoFactorInfo');
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(bLock) {
|
onShow(bLock) {
|
||||||
|
|
@ -236,7 +201,7 @@ class TwoFactorAuthSettings
|
||||||
onBuild() {
|
onBuild() {
|
||||||
if (this.capaTwoFactor) {
|
if (this.capaTwoFactor) {
|
||||||
this.processing(true);
|
this.processing(true);
|
||||||
Remote.getTwoFactor(this.onResult);
|
rl.pluginRemoteRequest(this.onResult, 'GetTwoFactorInfo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +226,7 @@ class TwoFactorAuthTestPopupView extends rl.pluginPopupView {
|
||||||
|
|
||||||
testCodeCommand() {
|
testCodeCommand() {
|
||||||
this.testing(true);
|
this.testing(true);
|
||||||
Remote.testTwoFactor(iError => {
|
Remote.verifyCode(iError => {
|
||||||
this.testing(false);
|
this.testing(false);
|
||||||
this.codeStatus(!iError);
|
this.codeStatus(!iError);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue