Skip to content

Commit 79770a8

Browse files
committed
Add otp_email_override support
UI is still to be implemented
1 parent 7d30386 commit 79770a8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

interface/web/login/otp.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,21 @@ 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+
$email_to = $data['otp_email_override'];
163165
}
164166
else {
165-
// Admin users are not related to a client, thus use the globally configured email address.
166-
$email_to = $mail_config['admin_mail'];
167+
$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']);
168+
if (!empty($clientuser['email'])) {
169+
$email_to = $clientuser['email'];
170+
}
171+
else {
172+
// Admin users are not related to a client, thus use the globally configured email address.
173+
$email_to = $mail_config['admin_mail'];
174+
}
167175
}
168176

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

0 commit comments

Comments
 (0)