Issue 163 (#168)

* Issue #163 - password reset warnings

* Fix errors showing when accounts don't have an email.  Fix errors when sending an email on password reset.  Prevent PHPMailer trying to use TLS when it's disabled.

Co-authored-by: Brian Lycett <brian.lycett.nonstaff@which.co.uk>
This commit is contained in:
Brian Lycett 2022-06-01 13:59:57 +01:00 committed by GitHub
parent 1db9635bf1
commit d79e58346d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -62,11 +62,12 @@ $people = ldap_get_user_list($ldap_connection);
foreach ($people as $account_identifier => $attribs){
$group_membership = ldap_user_group_membership($ldap_connection,$account_identifier);
if (isset($people[$account_identifier]['mail'])) { $this_mail = $people[$account_identifier]['mail']; } else { $this_mail = ""; }
print " <tr>\n <td><a href='${THIS_MODULE_PATH}/show_user.php?account_identifier=" . urlencode($account_identifier) . "'>$account_identifier</a></td>\n";
print " <td>" . $people[$account_identifier]['givenname'] . "</td>\n";
print " <td>" . $people[$account_identifier]['sn'] . "</td>\n";
print " <td>" . $people[$account_identifier]['mail'] . "</td>\n";
print " <td>$this_mail</td>\n";
print " <td>" . implode(", ", $group_membership) . "</td>\n";
print " </tr>\n";
}

View File

@ -102,11 +102,11 @@ foreach ($attribute_map as $attribute => $attr_r) {
if (isset($_GET['account_request'])) {
$givenname[0]=filter_var($_GET['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$new_account_r['givenname'] = $givenname;
$new_account_r['givenname'] = $givenname[0];
unset($new_account_r['givenname']['count']);
$sn[0]=filter_var($_GET['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$new_account_r['sn'] = $sn;
$new_account_r['sn'] = $sn[0];
unset($new_account_r['sn']['count']);
$mail[0]=filter_var($_GET['email'], FILTER_SANITIZE_EMAIL);

View File

@ -184,12 +184,12 @@ if ($ldap_search) {
include_once "mail_functions.inc.php";
$mail_body = parse_mail_text($new_account_mail_body, $password, $account_identifier, $givenname, $sn);
$mail_subject = parse_mail_text($new_account_mail_subject, $password, $account_identifier, $givenname, $sn);
$mail_body = parse_mail_text($new_account_mail_body, $password, $account_identifier, $givenname[0], $sn[0]);
$mail_subject = parse_mail_text($new_account_mail_subject, $password, $account_identifier, $givenname[0], $sn[0]);
$sent_email = send_email($mail,"$givenname $sn",$mail_subject,$mail_body);
$sent_email = send_email($mail[0],"${givenname[0]} ${sn[0]}",$mail_subject,$mail_body);
if ($sent_email) {
$sent_email_message .= " An email sent to $mail.";
$sent_email_message .= " An email sent to ${mail[0]}.";
}
else {
$sent_email_message .= " Unfortunately the email wasn't sent; check the logs for more information.";

View File

@ -64,6 +64,7 @@ function send_email($recipient_email,$recipient_name,$subject,$body) {
if ($SMTP['tls'] == TRUE) { $mail->SMTPSecure = 'tls'; }
if ($SMTP['ssl'] == TRUE) { $mail->SMTPSecure = 'ssl'; }
$mail->SMTPAutoTLS = false;
$mail->setFrom($EMAIL['from_address'], $EMAIL['from_name']);
$mail->addAddress($recipient_email, $recipient_name);
$mail->Subject = $subject;