mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-25 07:16:21 +08:00
Bugfix: Admin -> Contacts PDO test failed when using different AddressBookInterface
This commit is contained in:
parent
27b19ef29d
commit
083b6988ee
2 changed files with 20 additions and 13 deletions
|
@ -465,13 +465,13 @@ class Actions
|
|||
return $this->oDomainProvider;
|
||||
}
|
||||
|
||||
public function AddressBookProvider(?Model\Account $oAccount = null, bool $bForceEnable = false): Providers\AddressBook
|
||||
public function AddressBookProvider(?Model\Account $oAccount = null): Providers\AddressBook
|
||||
{
|
||||
if (null === $this->oAddressBookProvider) {
|
||||
$oDriver = null;
|
||||
try {
|
||||
// if ($bForceEnable || $this->oConfig->Get('contacts', 'enable', false)) {
|
||||
if ($bForceEnable || $this->GetCapa(Enumerations\Capa::CONTACTS)) {
|
||||
// if ($this->oConfig->Get('contacts', 'enable', false)) {
|
||||
if ($this->GetCapa(Enumerations\Capa::CONTACTS)) {
|
||||
$oDriver = $this->fabrica('address-book', $oAccount);
|
||||
}
|
||||
if ($oAccount && $oDriver) {
|
||||
|
@ -479,8 +479,9 @@ class Actions
|
|||
$oDriver->setDAVClientConfig($this->getContactsSyncData($oAccount));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\SnappyMail\LOG::error('AddressBook', $e->getMessage()."\n".$e->getTraceAsString());
|
||||
$oDriver = null;
|
||||
\SnappyMail\LOG::error('AddressBook', $e->getMessage());
|
||||
// $oDriver = new Providers\AddressBook\PdoAddressBook();
|
||||
}
|
||||
$this->oAddressBookProvider = new Providers\AddressBook($oDriver);
|
||||
$this->oAddressBookProvider->SetLogger($this->oLogger);
|
||||
|
|
|
@ -75,7 +75,7 @@ class ActionsAdmin extends Actions
|
|||
$this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoType', 'contacts', 'type', 'string', function ($sType) use ($self) {
|
||||
return \RainLoop\Providers\AddressBook\PdoAddressBook::validPdoType($sType);
|
||||
return Providers\AddressBook\PdoAddressBook::validPdoType($sType);
|
||||
});
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'CapaAdditionalAccounts', 'webmail', 'allow_additional_accounts', 'bool');
|
||||
|
@ -141,17 +141,23 @@ class ActionsAdmin extends Actions
|
|||
$this->IsAdminLoggined();
|
||||
|
||||
$oConfig = $this->Config();
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoDsn', 'contacts', 'pdo_dsn', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy');
|
||||
|
||||
$self = $this;
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoType', 'contacts', 'type', 'string', function ($sType) use ($self) {
|
||||
return \RainLoop\Providers\AddressBook\PdoAddressBook::validPdoType($sType);
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoType', 'contacts', 'type', 'string', function ($sType) {
|
||||
return Providers\AddressBook\PdoAddressBook::validPdoType($sType);
|
||||
});
|
||||
|
||||
$sTestMessage = $this->AddressBookProvider(null, true)->Test();
|
||||
$sTestMessage = '';
|
||||
try {
|
||||
$AddressBook = new Providers\AddressBook(new Providers\AddressBook\PdoAddressBook());
|
||||
$AddressBook->SetLogger($this->oLogger);
|
||||
$sTestMessage = $AddressBook->Test();
|
||||
} catch (\Throwable $e) {
|
||||
\SnappyMail\LOG::error('AddressBook', $e->getMessage()."\n".$e->getTraceAsString());
|
||||
$sTestMessage = $e->getMessage();
|
||||
}
|
||||
|
||||
return $this->DefaultResponse(array(
|
||||
'Result' => '' === $sTestMessage,
|
||||
'Message' => \MailSo\Base\Utils::Utf8Clear($sTestMessage)
|
||||
|
@ -300,7 +306,7 @@ class ActionsAdmin extends Actions
|
|||
{
|
||||
$user = (string) $this->GetActionParam('username', '');
|
||||
$secret = (string) $this->GetActionParam('TOTP', '');
|
||||
$issuer = \rawurlencode(\RainLoop\API::Config()->Get('webmail', 'title', 'SnappyMail'));
|
||||
$issuer = \rawurlencode(API::Config()->Get('webmail', 'title', 'SnappyMail'));
|
||||
$QR = \SnappyMail\QRCode::getMinimumQRCode(
|
||||
"otpauth://totp/{$issuer}:{$user}?secret={$secret}&issuer={$issuer}",
|
||||
// "otpauth://totp/{$user}?secret={$secret}",
|
||||
|
@ -323,7 +329,7 @@ class ActionsAdmin extends Actions
|
|||
return $sToken;
|
||||
}
|
||||
|
||||
private function setConfigFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null): void
|
||||
private function setConfigFromParams(Config\Application $oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null): void
|
||||
{
|
||||
if ($this->HasActionParam($sParamName)) {
|
||||
$sValue = $this->GetActionParam($sParamName, '');
|
||||
|
|
Loading…
Reference in a new issue