Add new function to overwrite the cryptkey

This is needed to prevent SnappyMail to ask the user for the old (maybe forgotten) ldap password
This commit is contained in:
cm-schl 2024-05-14 17:24:26 +02:00
parent f8af48cf47
commit 23fe3a946b
3 changed files with 29 additions and 1 deletions

View file

@ -5,6 +5,7 @@ use MailSo\Log\Logger;
use RainLoop\Actions;
use RainLoop\Model\AdditionalAccount;
use RainLoop\Model\MainAccount;
use RainLoop\Providers\Storage\Enumerations\StorageType;
class LdapMailAccounts
{
@ -176,6 +177,18 @@ class LdapMailAccounts
return $oActions->FalseResponse(__FUNCTION__);
}
//SnappyMail saves the passwords of the additional accounts by encrypting them using a cryptkey that is saved in the file .cryptkey
//When the password of the main account changes, SnappyMail asks the user for the old password to reencrypt the keys with the new userpassword.
//On a password change using ldap (or when the password has been forgotten by the user) this makes us some problems. Therefore overwrite
//the .cryptkey file in order to always accept the actual ldap password of the user. This has side effects on pgp keys!
//See https://github.com/the-djmaze/snappymail/issues/1570#issuecomment-2085528061
if ($this->config->bool_overwrite_cryptkey) {
if (!$oActions->StorageProvider()->Put($oAccount, StorageType::ROOT, '.cryptkey', "")) {
$this->logger->Write("Could not overwrite the .cryptkey file!", \LOG_WARNING, self::LOG_KEY);
return $oActions->FalseResponse(__FUNCTION__);
}
}
$aAccounts = $oActions->GetAccounts($oAccount);
//Search for accounts with suffix " (LDAP)" at the end of the name that were created by this plugin and initially remove them from the