public function profile()
 {
     if ($this->request->isGet()) {
         $data['session_user'] = $this->session->get('user');
         $user = \PhalconRest\Models\Users::findFirst(array("username = :username:", 'bind' => array('username' => $data['session_user']['username'])));
         $data['message'] = 'you are ok';
         $data['user'] = $user;
         return $this->respond($data);
     }
 }
Exemplo n.º 2
0
 /**
  * run after login to reset the local token
  */
 public function resetToken($wipe = false)
 {
     $search = "email = '{$this->email}' and active = '1'";
     $user = \PhalconRest\Models\Users::findFirst($search);
     if (!$user) {
         throw new HTTPException("No valid user account was found", 401, array('dev' => "This has to be a bug to have made it this far.", 'internalCode' => '760708898897686'));
         break;
     }
     if ($wipe) {
         $this->token = $user->token = null;
         $this->expiresOn = $user->token_expires = null;
         // last login
     } else {
         $this->token = $user->token = $this->generateToken();
         $this->expiresOn = $user->token_expires = $this->generateExpiration();
         // last login
     }
     return $user->save();
 }