Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function create($user, $pass) {
*/
class Hm_Auth_IMAP extends Hm_Auth {

private $imap_instance = null;
/**
* Assign site config, get required libs
* @param object $config site config
Expand All @@ -163,6 +164,12 @@ public function __construct($config) {
include_once APP_PATH.'modules/sievefilters/hm-sieve.php';
}



public function get_imap() {
return $this->imap_instance;
}

/* IMAP authentication server settings */
private $imap_settings = [];

Expand All @@ -181,6 +188,7 @@ private function check_connection($imap) {
return false;
}
else {
error_log(sprintf('IMAP AUTH failed for %s', $this->imap_settings['username']));
Hm_Debug::add($imap->show_debug(true));
Hm_Debug::add(sprintf('IMAP AUTH failed for %s', $this->imap_settings['username']));
return false;
Expand All @@ -194,10 +202,10 @@ private function check_connection($imap) {
* @return bool true if authentication worked
*/
public function check_credentials($user, $pass) {
$imap = new Hm_IMAP();
$this->imap_instance = new Hm_IMAP();;
list($server, $port, $tls, $sieve_config, $sieve_tls_mode) = get_auth_config($this->site_config, 'imap');
if (!$user || !$pass || !$server || !$port) {
Hm_Debug::add($imap->show_debug(true));
Hm_Debug::add($this->imap_instance->show_debug(true));
Hm_Debug::add('Invalid IMAP auth configuration settings');
return false;
}
Expand All @@ -207,7 +215,7 @@ public function check_credentials($user, $pass) {
'sieve_config_host' => $sieve_config,
'sieve_tls' => $sieve_tls_mode
];
return $this->check_connection($imap);
return $this->check_connection($this->imap_instance);
}

/**
Expand Down
Loading