Skip to content

Commit f8923da

Browse files
author
Till Brehm
committed
Merge branch '2558-two-factor-authentication-followup' into 'develop'
Extend Two-factor authentication Closes #2558 See merge request ispconfig/ispconfig3!1594
2 parents ba91d91 + 3ddebfe commit f8923da

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

interface/web/login/otp.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,25 @@ function finish_2fa_success($msg = '') {
157157
$app->ispcmail->setOptions($mail_config);
158158
}
159159

160-
$clientuser = $app->db->queryOneRecord('SELECT email FROM sys_user u LEFT JOIN client c ON (u.client_id=c.client_id) WHERE u.userid = ?', $_SESSION['s_pending']['user']['userid']);
161-
if (!empty($clientuser['email'])) {
162-
$email_to = $clientuser['email'];
160+
$sys_user = $app->db->queryOneRecord('SELECT otp_data FROM sys_user WHERE userid = ?', $_SESSION['s_pending']['user']['userid']);
161+
$data = json_decode($sys_user['otp_data'], TRUE);
162+
163+
if (!empty($data['otp_email_override'] )) {
164+
// Handle otp_email_override.
165+
$email_to = $data['otp_email_override'];
163166
}
164167
else {
165-
// Admin users are not related to a client, thus use the globally configured email address.
166-
$email_to = $mail_config['admin_mail'];
168+
$clientuser = $app->db->queryOneRecord('SELECT email FROM sys_user u LEFT JOIN client c ON (u.client_id=c.client_id) WHERE u.userid = ?', $_SESSION['s_pending']['user']['userid']);
169+
if (!empty($clientuser['email'])) {
170+
$email_to = $clientuser['email'];
171+
}
172+
elseif(!empty($mail_config['admin_mail'])) {
173+
// Admin users are not related to a client, thus use the globally configured email address.
174+
$email_to = $mail_config['admin_mail'];
175+
}
176+
else {
177+
$app->error('No mail address available to sent an OTP code to.', 'index.php');
178+
}
167179
}
168180

169181
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);

0 commit comments

Comments
 (0)