Exemple #1
0
/*     |  _  // _ \/ __| __| | | / __|   / / \__, |    */
/*     | | \ \  __/ (__| |_| |_| \__ \  / /_   / /     */
/*     |_|  \_\___|\___|\__|\__,_|___/ |____| /_/      */
/*                                                     */
/*                Date: 15/10/2015 23:55               */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\manager\SecurityManager;
use MealBooker\model\User;
use MealBooker\models\dao\CompanyDao;
use MealBooker\models\dao\RoleDao;
use MealBooker\models\dao\UserDao;
if (!SecurityManager::get()->getCurrentUser($_SESSION)->isAdmin()) {
    header('Location:' . WEB_PATH);
}
$userDao = new UserDao($em);
$roleDao = new RoleDao($em);
$error = null;
$info = null;
//save mode
if (isset($_POST['lastname']) && isset($_POST['firstname']) && isset($_POST['mail']) && isset($_POST['phone']) && isset($_POST['role']) && isset($_POST['company']) && isset($_POST['id']) && isset($_POST['state'])) {
    try {
        $user = $userDao->getByPrimaryKey($_POST['id']);
        if ($user == null) {
            $user = new User();
        }
        $user->setFirstName($_POST['firstname']);
        $user->setLastName($_POST['lastname']);
        $user->setMail($_POST['mail']);
        $user->setPhoneNumber($_POST['phone']);
        $user->setOptIn(isset($_POST['optin']) ? true : false);
Exemple #2
0
/*                                                     */
/*                Date: 23/09/2015                     */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\manager\MailManager;
use MealBooker\manager\SecurityManager;
use MealBooker\model\User;
use MealBooker\models\dao\CompanyDao;
use MealBooker\models\dao\RoleDao;
use MealBooker\models\dao\UserDao;
use MealBooker\utils\Utils;
$error = null;
$info = null;
if (isset($_POST) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['firstName']) && isset($_POST['lastName']) && isset($_POST['idEntreprise']) && isset($_POST['password']) && isset($_POST['passwordCheck'])) {
    $companyDao = new CompanyDao($em);
    $userDao = new UserDao($em);
    $roleDao = new RoleDao($em);
    try {
        if ($userDao->getUserByMail($_POST['email']) != null) {
            throw new Exception("Ce mail est déjà utilisé par un compte existant");
        }
        //set user data
        $user = new User();
        $user->setLastName($_POST['lastName']);
        $user->setFirstName($_POST['firstName']);
        $user->setMail($_POST['email']);
        $user->setPhoneNumber($_POST['phone']);
        //check password validation
        if ($_POST['password'] != $_POST['passwordCheck']) {
            throw new Exception("Le champs mot de passe et confirmation mot de passe doivent étre identiques");
        }
 /**
  * logout user by session id
  * @param $session
  */
 public function logOutUser($session)
 {
     try {
         $userDao = new UserDao(self::$em);
         $user = $this->getCurrentUser($session);
         if ($user != null) {
             $user->setSession('');
             $userDao->save($user);
             return true;
         }
         return false;
     } catch (Exception $ex) {
         var_dump($ex);
     }
 }
/*-----------------------------------------------------*/
/*      _____           _               ___   ___      */
/*     |  __ \         | |             |__ \ / _ \     */
/*     | |__) |___  ___| |_ _   _ ___     ) | (_) |    */
/*     |  _  // _ \/ __| __| | | / __|   / / \__, |    */
/*     | | \ \  __/ (__| |_| |_| \__ \  / /_   / /     */
/*     |_|  \_\___|\___|\__|\__,_|___/ |____| /_/      */
/*                                                     */
/*                Date: 23/09/2015                     */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\model\User;
use MealBooker\models\dao\UserDao;
$error = null;
if (isset($_GET['authToken'])) {
    $userDao = new UserDao($em);
    $user = $userDao->getBySession($_GET['authToken']);
    if ($user != null) {
        //reset session and enable user
        $user->setSession(null);
        $user->setStatus(1);
        //save user
        $userDao->save($user);
    } else {
        $error = "Une erreur est survenue";
    }
}
?>
<div class="col-md-6 col-md-offset-3">

    <h2>Bienvenue</h2>
Exemple #5
0
<?php

/*-----------------------------------------------------*/
/*      _____           _               ___   ___      */
/*     |  __ \         | |             |__ \ / _ \     */
/*     | |__) |___  ___| |_ _   _ ___     ) | (_) |    */
/*     |  _  // _ \/ __| __| | | / __|   / / \__, |    */
/*     | | \ \  __/ (__| |_| |_| \__ \  / /_   / /     */
/*     |_|  \_\___|\___|\__|\__,_|___/ |____| /_/      */
/*                                                     */
/*                Date: 15/10/2015 23:55               */
/*                 All right reserved                  */
/*-----------------------------------------------------*/
use MealBooker\models\dao\UserDao;
use MealBooker\utils\Utils;
$userDao = new UserDao($em);
?>
<div class="row">

    <table class="table table-striped">
        <thead>
        <tr>
            <th>#</th>
            <th>Nom</th>
            <th>Mail</th>
            <th>Tél.</th>
            <th>Créé le</th>
            <th>Société</th>
            <th>Démarchable</th>
            <th>Rôle</th>
            <th>Statut</th>
             $user->setRestoreToken(null);
             $user->setPassword(SecurityManager::hashPassword($password, $user->getSalt()));
             $userDao->save($user);
             $message = 'Votre mot de passe est validé, vous pouvez maintenant vous <a href="' . WEB_PATH . '">connecter</a>';
         } else {
             throw new Exception("Une erreur est survenue");
         }
     } catch (Exception $ex) {
         $error = $ex->getMessage();
     }
 } else {
     if (isset($_GET['token']) && sizeof($_GET['token']) > 0) {
         //query validation
         try {
             $token = $_GET['token'];
             $userDao = new UserDao($em);
             $user = $userDao->getByRestoreToken($token);
             if ($user == null) {
                 throw new Exception("Jeton de restauration inconnu");
             } else {
                 if ($user->getUpdated() > (new DateTime())->add(new DateInterval('P1D'))) {
                     throw new Exception('Jeton de restauration expiré');
                 } else {
                     $mod = "RESTOR";
                 }
             }
         } catch (Exception $ex) {
             $error = $ex->getMessage();
         }
     }
 }