From 0c12be9b2d79ad294f8431470ae006bb78a497bd Mon Sep 17 00:00:00 2001 From: christer kahasha <62720246+christer77@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:26:52 +0100 Subject: [PATCH] [FIX]Error Ocurred when attempting Microsoft's email oauth2 setup --- modules/imap/functions.php | 2 +- modules/imap_folders/modules.php | 10 +++++----- modules/nux/modules.php | 2 +- modules/nux/site.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/imap/functions.php b/modules/imap/functions.php index 24d6048a18..3f17545ef2 100644 --- a/modules/imap/functions.php +++ b/modules/imap/functions.php @@ -1093,7 +1093,7 @@ function clear_existing_reply_details($session) { */ if (!hm_exists('imap_authed')) { function imap_authed($imap) { - return is_object($imap) && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'selected'); + return is_object($imap) && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'selected' || $imap->get_state() == 'connected'); }} /** diff --git a/modules/imap_folders/modules.php b/modules/imap_folders/modules.php index 4e926b7d4c..42e4783034 100644 --- a/modules/imap_folders/modules.php +++ b/modules/imap_folders/modules.php @@ -101,7 +101,7 @@ public function process() { $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); - if (!is_object($imap) || $imap->get_state() != 'authenticated') { + if (!is_object($imap) || ($imap->get_state() != 'authenticated' && $imap->get_state() != 'connected')) { Hm_Msgs::add('ERRUnable to connect to the selected IMAP server'); return; } @@ -135,7 +135,7 @@ public function process() { $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); - if (!is_object($imap) || $imap->get_state() != 'authenticated') { + if (!is_object($imap) || ($imap->get_state() != 'authenticated' && $imap->get_state() != 'connected')) { Hm_Msgs::add('ERRUnable to connect to the selected IMAP server'); return; } @@ -184,7 +184,7 @@ public function process() { } $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); - if (is_object($imap) && $imap->get_state() == 'authenticated') { + if (is_object($imap) && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'connected')) { $new_folder = prep_folder_name($imap, $form['folder'], false, $parent_str); if ($new_folder && $imap->create_mailbox($new_folder)) { Hm_Msgs::add('Folder created'); @@ -212,7 +212,7 @@ public function process() { if (array_key_exists('parent', $this->request->post)) { $parent_str = $this->request->post['parent']; } - if (is_object($imap) && $imap->get_state() == 'authenticated') { + if (is_object($imap) && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'connected')) { $old_folder = prep_folder_name($imap, $form['folder'], true); $new_folder = prep_folder_name($imap, $form['new_folder'], false, $parent_str); if ($new_folder && $old_folder && $imap->rename_mailbox($old_folder, $new_folder)) { @@ -273,7 +273,7 @@ public function process() { if ($success) { $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); - if (is_object($imap) && $imap->get_state() == 'authenticated') { + if (is_object($imap) && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'connected')) { $del_folder = prep_folder_name($imap, $form['folder'], true); if ($this->module_is_supported('sievefilters') && $this->user_config->get('enable_sieve_filter_setting', DEFAULT_ENABLE_SIEVE_FILTER)) { if (is_mailbox_linked_with_filters($del_folder, $form['imap_server_id'], $this)) { diff --git a/modules/nux/modules.php b/modules/nux/modules.php index 905251b8dd..823db86dea 100644 --- a/modules/nux/modules.php +++ b/modules/nux/modules.php @@ -184,7 +184,7 @@ public function process() { return; } $imap = Hm_IMAP_List::connect($new_id, false); - if ($imap && $imap->get_state() == 'authenticated') { + if ($imap && ($imap->get_state() == 'authenticated' || $imap->get_state() == 'connected')) { if (isset($details['smtp'])) { Hm_SMTP_List::add(array( 'name' => $details['name'], diff --git a/modules/nux/site.js b/modules/nux/site.js index d7dbdef53b..1bbd7794cb 100644 --- a/modules/nux/site.js +++ b/modules/nux/site.js @@ -53,11 +53,11 @@ var display_final_nux_step = function(res) { {'name': 'imap_server_id', value: res.nux_server_id}, {'name': 'imap_service_name', value: res.nux_service_name}], function () { - Hm_Utils.redirect(); + Hm_Utils.redirect('?page=servers'); } ); } else { - Hm_Utils.redirect(); + Hm_Utils.redirect('?page=servers'); } } };