예제 #1
0
 public function handle(User $user)
 {
     $conn = $this->app['db'];
     $session = $this->app['session'];
     $loggedUser = $conn->fetchAssoc('SELECT * FROM user WHERE username = ? AND status = ?', [$user->getUsername(), "active"]);
     if (count($loggedUser) > 0) {
         $passCheck = password_verify($user->getPassword(), $loggedUser['password']);
         if ($passCheck) {
             $session->set('role', ['value' => 'user']);
             $session->set('userId', ['value' => $loggedUser['id']]);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
예제 #2
0
 public function handle(User $user)
 {
     $conn = $this->app['db'];
     $conn->insert('user', array('username' => $user->getUsername(), 'password' => password_hash($user->getPassword(), PASSWORD_DEFAULT), 'email' => $user->getEmail(), 'status' => $user::DEFAULT_STATUS, 'created' => date("y-m-d"), 'updated' => date("y-m-d")));
 }