function login() { if (!isset($_POST['name']) || !isset($_POST['pass'])) { http_status_code(HTTP_BAD_REQUEST); echo 'name and pass params required'; } $userInfo = getUserRow($_POST['name']); if (count($userInfo) != 1) { return; } $userInfo = $userInfo[0]; if (!password_verify($_POST['pass'], $userInfo['pass'])) { return; } setSessionUser($userInfo['id'], $userInfo['name']); }
function auth_user() { global $usr, $login; $login->verify(); if ($login->userid != 0) { //set up $usr array $userRow = getUserRow($login->userid); $usr['username'] = $userRow['username']; $usr['hiddenCacheCount'] = $userRow['hidden_count']; $usr['logNotesCount'] = $userRow['log_notes_count']; $usr['userFounds'] = $userRow['founds_count']; $usr['notFoundsCount'] = $userRow['notfounds_count']; $usr['userid'] = $login->userid; $usr['email'] = $userRow['email']; $usr['country'] = $userRow['country']; $usr['latitude'] = $userRow['latitude']; $usr['longitude'] = $userRow['longitude']; } else { $usr = false; } return; }
function auth_user() { global $usr, $login; $login->verify(); $applicationContainer = \lib\Objects\ApplicationContainer::Instance(); if ($login->userid != 0) { //set up $usr array $applicationContainer->setLoggedUser(new lib\Objects\User\User(array('userId' => $login->userid))); $userRow = getUserRow($login->userid); $usr['username'] = $userRow['username']; $usr['hiddenCacheCount'] = $userRow['hidden_count']; $usr['logNotesCount'] = $userRow['log_notes_count']; $usr['userFounds'] = $userRow['founds_count']; $usr['notFoundsCount'] = $userRow['notfounds_count']; $usr['userid'] = $login->userid; $usr['email'] = $userRow['email']; $usr['country'] = $userRow['country']; $usr['latitude'] = $userRow['latitude']; $usr['longitude'] = $userRow['longitude']; } else { $usr = false; } return; }
/** * Recupere l'enregistrement a partir de son id * @param $db database * @param $usridusr identifiant de l'enregistrement a recuperer */ static function getUser($db, $usridusr) { $row = getUserRow($db, $usridusr); return User_model::User_modelFromRow($row); }