From 1d344bdc70d61939f0a505960e87fd18ea8c8d54 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 14 Oct 2019 14:05:34 +0200 Subject: Refine old/test account merging logic --- modules/main.inc.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'modules/main.inc.php') diff --git a/modules/main.inc.php b/modules/main.inc.php index db62096..6119814 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -62,22 +62,23 @@ class Page_Main extends Page { $data = User::getData(); $data['organization'] = User::getOrganizationName(); - // Shoe testacc merge form if organization has test accounts - $res = Database::queryFirst('SELECT Count(*) as cnt FROM user WHERE organizationid = :oid', array( + // Show testacc merge form if organization has test accounts + $res = Database::queryFirst('SELECT Count(*) as cnt FROM user WHERE organizationid = :oid AND Length(password) <> 0', array( 'oid' => User::getOrganizationId() )); - if ($res !== false && $res['cnt'] > 0) { - $data['testacc'] = true; - $mail = trim(User::getMail()); - if (!empty($mail)) { - $existing = Database::queryFirst('SELECT userid FROM user WHERE email = :email LIMIT 1', array( - 'email' => $mail - )); - if ($existing !== false) { - $data['testlogin'] = $existing['userid']; - } + $mail = trim(User::getMail()); + if (!empty($mail)) { + $existing = Database::queryFirst('SELECT userid FROM user + WHERE email = :email AND lastname = :ln AND firstname = :fn LIMIT 1', array( + 'email' => $mail, + 'fn' => User::getFirstName(), + 'ln' => User::getLastName(), + )); + if ($existing !== false) { + $data['testlogin'] = $existing['userid']; } } + $data['testacc'] = ($res !== false && $res['cnt'] > 0) || !empty($existing); $data['suite'] = CONFIG_SUITE; $data['idm'] = CONFIG_IDM; Render::addTemplate('main/deploy', $data); -- cgit v1.2.3-55-g7522