mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added domain matcher test for #689
This commit is contained in:
parent
d468bac551
commit
08baff9e64
4 changed files with 57 additions and 14 deletions
|
|
@ -11,10 +11,26 @@ import { DomainAliasPopupView } from 'View/Popup/DomainAlias';
|
|||
export class AdminSettingsDomains /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.domains = DomainAdminStore;
|
||||
|
||||
this.username = ko.observable('');
|
||||
this.domainForDeletion = ko.observable(null).askDeleteHelper();
|
||||
}
|
||||
|
||||
testUsername() {
|
||||
// TODO: find domain matching username
|
||||
Remote.request('AdminDomainMatch',
|
||||
(iError, oData) => {
|
||||
if (oData?.Result?.domain) {
|
||||
alert('Matched domain: ' + oData.Result.domain.name);
|
||||
} else {
|
||||
alert('No domain match');
|
||||
}
|
||||
},
|
||||
{
|
||||
username: this.username()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
createDomain() {
|
||||
showScreenPopup(DomainPopupView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ trait UserAuth
|
|||
/**
|
||||
* @throws \RainLoop\Exceptions\ClientException
|
||||
*/
|
||||
public function LoginProcess(string &$sEmail, string &$sPassword, bool $bSignMe = false, bool $bMainAccount = true): Account
|
||||
protected function resolveLoginCredentials(string &$sEmail, string &$sPassword, string &$sLogin): void
|
||||
{
|
||||
$sInputEmail = $sEmail;
|
||||
|
||||
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sEmail));
|
||||
|
||||
$sEmail = \MailSo\Base\Utils::Trim($sEmail);
|
||||
|
|
@ -101,22 +99,30 @@ trait UserAuth
|
|||
|
||||
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sEmail, &$sPassword));
|
||||
|
||||
if (!\str_contains($sEmail, '@') || !\strlen($sPassword)) {
|
||||
$this->loginErrorDelay();
|
||||
|
||||
throw new ClientException(Notifications::InvalidInputArgument);
|
||||
}
|
||||
|
||||
$this->Logger()->AddSecret($sPassword);
|
||||
|
||||
$sLogin = $sEmail;
|
||||
if ($this->Config()->Get('login', 'login_lowercase', true)) {
|
||||
$sLogin = \mb_strtolower($sLogin);
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sLogin, &$sPassword));
|
||||
|
||||
$this->Logger()->AddSecret($sPassword);
|
||||
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sLogin, &$sPassword));
|
||||
$this->Logger()->AddSecret($sPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \RainLoop\Exceptions\ClientException
|
||||
*/
|
||||
public function LoginProcess(string &$sEmail, string &$sPassword, bool $bSignMe = false, bool $bMainAccount = true): Account
|
||||
{
|
||||
$sInputEmail = $sEmail;
|
||||
|
||||
$sLogin = '';
|
||||
$this->resolveLoginCredentials($sEmail, $sPassword, $sLogin);
|
||||
|
||||
if (!\str_contains($sEmail, '@') || !\strlen($sPassword)) {
|
||||
$this->loginErrorDelay();
|
||||
throw new ClientException(Notifications::InvalidInputArgument);
|
||||
}
|
||||
|
||||
$oAccount = null;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -253,6 +253,23 @@ class ActionsAdmin extends Actions
|
|||
));
|
||||
}
|
||||
|
||||
public function DoAdminDomainMatch() : array
|
||||
{
|
||||
$sEmail = $this->GetActionParam('username');
|
||||
$sPassword = '********';
|
||||
$sLogin = '';
|
||||
$this->resolveLoginCredentials($sEmail, $sPassword, $sLogin);
|
||||
$oDomain = \str_contains($sEmail, '@')
|
||||
? $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true)
|
||||
: null;
|
||||
return $this->DefaultResponse(__FUNCTION__, array(
|
||||
'email' => $sEmail,
|
||||
'login' => $sLogin,
|
||||
'domain' => $oDomain,
|
||||
'whitelist' => $oDomain ? $oDomain->ValidateWhiteList($sEmail, $sLogin) : null
|
||||
));
|
||||
}
|
||||
|
||||
public function DoAdminDomainTest() : array
|
||||
{
|
||||
$this->IsAdminLoggined();
|
||||
|
|
|
|||
|
|
@ -32,3 +32,7 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<input data-i18n="[placeholder]GLOBAL/USERNAME" data-bind="textInput: username">
|
||||
<button class="btn" data-i18n="GLOBAL/TEST" data-bind="click: testUsername"></button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue