Example #1
0
 /**
  * Sets the current user using the UserId session variable and the data mapper
  */
 public function addLoggedInUserDataToContext()
 {
     if (Session::exists('UserId')) {
         $userId = Session::get('UserId');
         $where = '`UserId` = ' . $userId;
         $user = $this->userMapper->findRow($where);
         $this->context['user'] = $user->toArray();
     }
 }
Example #2
0
 /**
  * Logs the user in, ie. sets the session variable UserId for correct login data
  *
  * @param string $username
  * @param string $password
  * @return boolean True in case of success, false instead
  */
 public function login($username, $password)
 {
     $where = '`username` = \'' . $username . '\' AND `password` = \'' . $password . '\'';
     $user = $this->userMapper->findRow($where);
     if (false !== $user) {
         Session::set('UserId', $user->getUserId());
         return true;
     }
     return false;
 }