/**
  * @param string $username
  * @param string $password
  *
  * @return bool
  */
 public function login($username, $password)
 {
     /** @var AdminUsers $user */
     $user = AdminUsers::findFirstByUsername($username);
     if (!$user || !$user->active || !$this->security->checkHash($password, $user->password)) {
         return false;
     }
     $this->_session->set($this->_config['session_key'], $user->id);
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Verify the start of an authorization request.  Verifies if the request token is valid.
  * Next step is the method authorizeFinish()
  *
  * Nota bene: this stores the current token, consumer key and callback in the _SESSION
  *
  * @exception OAuthException2 thrown when not a valid request
  * @return IOauthToken
  */
 public function authorizeVerify($manualToken = null)
 {
     $token = $manualToken ? $manualToken : $this->request->getParam('oauth_token', true);
     if (\is_array($token)) {
         $token = isset($token[0]) ? $token[0] : null;
     }
     $rs = $this->store->getConsumerRequestToken($token);
     if (!$rs) {
         throw new OauthException('Unknown token "' . $token . '"');
     }
     // We need to remember the callback
     $verify_oauth_token = $this->session->get('verify_oauth_token');
     if (empty($verify_oauth_token) && !$manualToken || strcmp($verify_oauth_token, $rs->token)) {
         $this->session->set('verify_oauth_token', $rs->token);
         $this->session->set('verify_oauth_consumer_key', $rs->getOauthServerRegistry()->consumer_key);
         $cb = $this->request->getParam('oauth_callback', true);
         /*if ($cb)
               $this->session->set('verify_oauth_callback', $cb);
           else*/
         $this->session->set('verify_oauth_callback', $rs->callback_url);
     }
     return $rs;
 }
Ejemplo n.º 3
0
 public function create(UserModelInterface $user)
 {
     $data = [self::INDEX_USERID => $user->getUserId(), self::INDEX_USERNAME => $user->getUsername(), self::INDEX_LOGINTIME => time(), self::INDEX_LASTACTIVE => time(), self::INDEX_REMOTEADDR => $this->auth->getServerAttr('REMOTE_ADDR'), self::INDEX_USERAGENT => $this->auth->getServerAttr('HTTP_USER_AGENT'), self::INDEX_ISACTIVE => true];
     $this->session->set(self::KEY, new Config($data));
     return $this;
 }