$isAdmin = $_POST['isAdmin']; $isAdmin = true; var_dump($isAdmin); } else { $isAdmin = false; var_dump($isAdmin); } $userManager = new UserPdoManager(); $accountManager = new AccountPdoManager(); $planManager = new RefPlanPdoManager(); //Verifie la disponibilité de l'adresse mail if ($userManager->checkEmailAvailability($email) != FALSE) { $accountId = new MongoId(); $userId = new MongoId(); //crypte le password $password = $userManager->encrypt($password); //@link http://www.php.net/manual/en/class.mongodate.php $time = time(); $end = $time + 30 * 24 * 60 * 60; // + 30 jours //info compte $account = array('_id' => $accountId, 'state' => new MongoInt32($state), 'idUser' => $userId, 'idRefPlan' => new MongoId($plan), 'storage' => (int) 0, 'ratio' => (int) 0, 'startDate' => new MongoDate($time), 'endDate' => new MongoDate($end)); $isAccountAdded = $accountManager->create($account); //Si aucun pb apres ajout du compte, ajoute l'user, sinon suppresion de user if ($isAccountAdded == TRUE) { //infos user $user = array('_id' => $userId, 'isAdmin' => $isAdmin, 'state' => new MongoInt32($state), 'idCurrentAccount' => $accountId, 'firstName' => _sanitize($firstname), 'lastName' => _sanitize($lastname), 'password' => $password, 'email' => $email, 'geolocation' => $geo, 'apiKey' => $userManager->generateGUID()); $isUserAdded = $userManager->create($user); if ($isUserAdded != TRUE) { //annule l'insertion de l'account $removeAccount = $accountManager->remove($account);
<?php //appel la session session_start(); //variable de session a false $loginOK = false; $projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/OwlEyes'; //require $projectRoot.'/controller/functions.php'; require $projectRoot . '/required.php'; //On check si loginForm est bien defini //S'il est defini alors on entre dans la condition if (isset($_POST['loginForm'])) { $email = $_POST['email']; $password = $_POST['password']; //Avant de se logger on verifie bien que les champs mail et password ne sont pas vide if (!empty($email) && !empty($password)) { $userPdoManager = new UserPdoManager(); $criteria = array('email' => $email, 'password' => $userPdoManager->encrypt($password), 'isAdmin' => true); $user = $userPdoManager->findOne($criteria); var_dump($user); if (!array_key_exists('error', $user)) { $_SESSION['owleyesOK'] = serialize($user); //redirection vers index header('Location:../index.php'); } else { $_SESSION['errorMessageLogin'] = $user['error']; header('Location:../pages/login.php'); die; } } }