- $login = $login . '@' . $globals->mail->domain;
- }
-
- // Checks if $login is a valid alias on the main domains.
- list($mbox, $fqdn) = explode('@', $login);
- if ($fqdn == $globals->mail->domain || $fqdn == $globals->mail->domain2) {
- $res = XDB::query('SELECT a.uid
- FROM accounts AS a
- INNER JOIN aliases AS al ON (al.uid = a.uid AND al.type IN (\'alias\', \'a_vie\'))
- WHERE al.alias = {?}', $mbox);
- if ($res->numRows()) {
- return $res->fetchOneCell();
- }
-
- if (preg_match('/^(.*)\.([0-9]{4})$/u', $mbox, $matches)) {
- $res = XDB::query('SELECT a.uid
- FROM accounts AS a
- INNER JOIN aliases AS al ON (al.uid = a.uid AND al.type IN (\'alias\', \'a_vie\'))
- INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET(\'owner\', ap.perms))
- INNER JOIN profiles AS p ON (p.pid = ap.pid)
- INNER JOIN profile_education AS pe ON (p.pid = pe.pid AND FIND_IN_SET(\'primary\', pe.flags))
- WHERE p.hrpid = {?} OR ((pe.entry_year <= {?} AND pe.grad_year >= {?}) AND al.alias = {?})
- GROUP BY a.uid',
- $matches[0], $matches[2], $matches[2], $matches[1]);
- if ($res->numRows() == 1) {
- return $res->fetchOneCell();
- }
- }
-
- throw new UserNotFoundException();
+ $res = XDB::fetchOneCell('SELECT uid
+ FROM email_source_account
+ WHERE email = {?}',
+ $login);
+ } else {
+ list($email, $domain) = explode('@', $login);
+ $res = XDB::fetchOneCell('SELECT s.uid
+ FROM email_source_account AS s
+ INNER JOIN email_virtual_domains AS m ON (s.domain = m.id)
+ INNER JOIN email_virtual_domains AS d ON (d.aliasing = m.id)
+ WHERE s.email = {?} AND d.name = {?}',
+ $email, $domain);