You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mods-for-HESK-Netsyms/api/dao/security/UserGateway.php

41 lines
1.0 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: user
* Date: 1/21/17
* Time: 4:23 PM
*/
namespace DataAccess\Security;
use BusinessLogic\Security\UserContextBuilder;
use DataAccess\CommonDao;
use Exception;
class UserGateway extends CommonDao {
/**
* @param $hashedToken string The pre-hashed token from Helpers::hashToken
* @param $heskSettings
* @return array|null User ResultSet if an active user for the token is found, null otherwise
*/
function getUserForAuthToken($hashedToken, $heskSettings) {
$this->init();
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "users` WHERE `id` = (
SELECT ``
FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "user_api_tokens`
WHERE `tokens`.`token` = " . hesk_dbEscape($hashedToken) . "
) AND `active` = '1'");
if (hesk_dbNumRows($rs) === 0) {
return null;
}
$row = hesk_dbFetchAssoc($rs);
$this->close();
return $row;
}
}