Skip to content

Commit

Permalink
Ref: Check the state after connection (#932)
Browse files Browse the repository at this point in the history
Ref: check state after authentication
  • Loading branch information
henochit authored Apr 14, 2024
1 parent db406ba commit 8409da5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ protected function output() {
<div>
<form>
<div class="form-floating mb-3">
<select class="form-select" id="srv_setup_stepper_provider" onchange="handleProviderChange(this) label="'.$this->trans('Provider').'">
<select class="form-select" id="srv_setup_stepper_provider" onchange="handleProviderChange(this)" label="'.$this->trans('Provider').'">
<option value="">'.$this->trans('Other').'</option>'.$serverList.'
</select>
<label for="srv_setup_stepper_provider">'.$this->trans('Provider').'</label>
Expand Down
9 changes: 7 additions & 2 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -2282,8 +2282,12 @@ function handleProviderChange(select) {
$("#srv_setup_stepper_imap_port").val(993);
}
}

function setDefaultReplyTo(val) {
$("#srv_setup_stepper_profile_reply_to").val(val);
}
function display_config_step(stepNumber) {
if(stepNumber == 2) {
if(stepNumber === 2) {

var isValid = true;

Expand All @@ -2303,9 +2307,10 @@ function display_config_step(stepNumber) {

let providerKey = getEmailProviderKey($('#srv_setup_stepper_email').val());
getServiceDetails(providerKey);
setDefaultReplyTo($('#srv_setup_stepper_email').val());
}

if(stepNumber == 3) {
if(stepNumber === 3) {
var requiredFields = [];
var isValid = true;

Expand Down
10 changes: 9 additions & 1 deletion modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,14 @@ function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $ima
}
}

return Hm_IMAP_List::service_connect($imap_server_id, $server, $user, $pass, false);
$imap = Hm_IMAP_List::connect($imap_server_id, false);

if (imap_authed($imap)) {
return $imap_server_id;
}else {
Hm_IMAP_List::del($imap_server_id);
Hm_Msgs::add('ERRAuthentication failed');
return null;
}
}
}
2 changes: 1 addition & 1 deletion modules/imap/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ protected function output() {
</div>
';

if (!$this->get('sieve_filters_enabled')) {
if ($this->get('sieve_filters_enabled')) {
$default_value = '';
$res .= '
Expand Down
13 changes: 9 additions & 4 deletions modules/smtp/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ function connect_to_smtp_server($address, $name, $port, $user, $pass, $tls, $con
'tls' => $tls);

$smtp_server_id = Hm_SMTP_List::add($smtp_list);
$server = Hm_SMTP_List::get($smtp_server_id, false);

$result = Hm_SMTP_List::service_connect($smtp_server_id, $server, $user, $pass, false);

return $result;
$smtp = Hm_SMTP_List::connect($smtp_server_id, false);
if (smtp_authed($smtp)) {
return $smtp_server_id;
}
else {
Hm_SMTP_List::del($smtp_server_id);
Hm_Msgs::add('ERRAuthentication failed');
return null;
}
}
}

Expand Down

0 comments on commit 8409da5

Please sign in to comment.