| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\Modules\MailMasterPassword; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | class Module extends \Aurora\System\Module\AbstractModule |
| 20: | { |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | public function init() |
| 26: | { |
| 27: | $this->subscribeEvent('Core::Login::before', array($this, 'onBeforLogin'), 10); |
| 28: | } |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | protected function cryptPassword($Password) |
| 37: | { |
| 38: | return crypt(trim($Password), \Aurora\System\Api::$sSalt); |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | public function onBeforLogin(&$aArgs, &$mResult) |
| 48: | { |
| 49: | $sPassword = $this->getConfig('Password', false); |
| 50: | |
| 51: | if ($sPassword !== false && !empty($sPassword) && $this->cryptPassword($aArgs['Password']) === $sPassword) { |
| 52: | $oAccount = \Aurora\Modules\Mail\Module::getInstance()->getAccountsManager()->getAccountUsedToAuthorize($aArgs['Login']); |
| 53: | if ($oAccount instanceof \Aurora\Modules\Mail\Models\MailAccount) { |
| 54: | $aArgs['Password'] = $oAccount->getPassword(); |
| 55: | } |
| 56: | } |
| 57: | } |
| 58: | |
| 59: | |
| 60: | public function UpdateSettings($MasterPassword) |
| 61: | { |
| 62: | $this->setConfig('Password', $this->cryptPassword($MasterPassword)); |
| 63: | return $this->saveModuleConfig(); |
| 64: | } |
| 65: | } |
| 66: | |