$_SESSION['locale'] = 'fr'; } include_once '../translations/label_' . $_SESSION['locale'] . '.php'; //entry const file translation if (isset($_SESSION['customer_email']) && !empty($_SESSION['customer_email'])) { header('Location: ../'); } if (isset($_GET['do']) && trim($_GET['do']) === 'logout') { //logout unset($_SESSION['customer_email']); unset($_SESSION['customer_id']); } if (count($_POST) > 0) { require_once '../Model/InitConsts.php'; require_once '../Manager/UtilitiesManager.php'; $a_cleaned_values = UtilitiesManager::checkEmptyDatasPost($_POST); if (is_array($a_cleaned_values)) { require_once '../Manager/DatabaseManager.php'; $dm = new DatabaseManager(); $output = $dm->fetchUser($a_cleaned_values['email'], $a_cleaned_values['password']); if (is_array($output)) { if ($output['password'] !== InitConsts::HASH_PASSWD) { $_SESSION['customer_email'] = $output['email']; $_SESSION['customer_id'] = $output['id']; header('Location: ../'); } else { $errorMsg = WRONG_LOGIN_PAGE . ' <a href="../firstLogin">login</a>'; } //if user try to login with PSK as password in classic login page } else { $errorMsg = $output;
namespace login; use Manager\DatabaseManager; use Manager\UtilitiesManager; session_start(); include_once '../translations/label_' . (isset($_SESSION['locale']) ? $_SESSION['locale'] : 'fr') . '.php'; //entry const file translation if (isset($_SESSION['customer_email']) && !empty($_SESSION['customer_email'])) { header('Location: ../order'); } if (count($_POST) > 0) { require_once '../Model/InitConsts.php'; require_once '../Manager/UtilitiesManager.php'; $a_cleaned_values = UtilitiesManager::checkEmptyDatasPost($_POST); if (is_array($a_cleaned_values)) { $firstLoginRequirements = UtilitiesManager::checkUserFirstLoginRequirement($a_cleaned_values); //especially that the passwd != PSK otherwise failure on affected_rows sql if (is_bool($firstLoginRequirements)) { require_once '../Manager/DatabaseManager.php'; $dm = new DatabaseManager(); $output = $dm->fetchUser($a_cleaned_values['email'], $a_cleaned_values['new_password']); //careful: new_password if (is_string($output)) { $output2 = $dm->updatePasswdAndlogin($a_cleaned_values); if (is_array($output2)) { $_SESSION['customer_email'] = $output2['email']; $_SESSION['customer_id'] = $output2['id']; header('Location: ../'); } else { $errorMsg = $output2; }