Example #1
0
 public function login($login, $password)
 {
     if ($this->isLogged()) {
         return null;
     }
     $user = User::findOneWhere(['login' => $login, 'valid' => true], null, ['id', 'login', 'password']);
     if (!is_null($user) && Password::verify($password, $user->getPassword())) {
         $this['user.id'] = $user->getId();
         return true;
     }
     return false;
 }
Example #2
0
<?php

require_once '../Common.php';
$common = \website\Common::getInstance();
$user = new \website\model\User();
$user->age = 15;
$user->login = '******' . rand();
$user->password = \website\utils\Password::hash('5a1v564a1v564a1');
$user->first_name = 'toto';
$user->last_name = 'caca';
var_dump($user->save());
echo '------------------------<br/>';
var_dump($user);
echo '------------------------<br/>';
$user->age = 16;
var_dump($user->save());
echo '------------------------<br/>';
var_dump($user);
echo '------------------------<br/>';
var_dump(\website\model\User::find());
echo '------------------------<br/>';
var_dump(\website\model\User::findOneWhere(['id'], [5]));
var_dump(\website\model\User::findOneWhere(['id' => 5]));
var_dump(\website\model\User::findOneWhere('id = ?', [5]));
Example #3
0
 public function testDelete()
 {
     $this->given($this->newTestedInstance())->if($this->testedInstance->login = self::login())->if($this->testedInstance->password = self::DEFAULT_PASSWORD)->if($this->testedInstance->role = self::STUDENT_ROLE)->if($this->testedInstance->first_name = self::DEFAULT_FIRST_NAME)->if($this->testedInstance->last_name = self::DEFAULT_LAST_NAME)->if($this->testedInstance->date_of_birth = self::DEFAULT_DATE)->if($this->testedInstance->address = self::DEFAULT_ADDRESS)->if($this->testedInstance->phone = self::DEFAULT_PHONE_NUMBER)->if($this->testedInstance->email = $this->mailAddress())->if($this->testedInstance->valid = true)->then->boolean($this->testedInstance->save())->isTrue()->given($notif = new Notification())->if($notif->message = "hey")->if($notif->read = 1)->if($notif->creation_date = date('Y-m-d H:i:s'))->if($notif->target_user_id = $this->testedInstance->getId())->then->boolean($notif->save())->isTrue()->given(\website\model\User::delete($this->testedInstance->getId()))->then->variable(\website\model\User::findOneWhere(['id' => $this->testedInstance->getId()]))->isNull()->variable(Notification::findOneWhere(['id' => $notif->getId()]))->isNull();
     //TODO test with module subscription
 }
 public function getUser($projection = '*')
 {
     return User::findOneWhere(['id'], [$this->getUserId()], $projection);
 }
Example #5
0
    <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="container">
    Hey <span id="greetingUserName">
    <?php 
if ($session->isLogged()) {
    $user = \website\model\User::findOneWhere('id = ?', $session['user.id'], 'login');
    echo htmlentities($user->getLogin());
} else {
    ?>
        buddy
    <?php 
}
?>
    </span>.
    <br/>
    There's hard work over here.
</div>
<!-- /container -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>