Esempio n. 1
0
 public function find()
 {
     if ($this->card === null && CardRecord::check($this->HardID)) {
         $this->card = CardRecord::findCard($this->HardID);
     }
     return $this->card;
 }
Esempio n. 2
0
 /** @inheritdoc */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if (!empty($this->Login)) {
             $this->user = $this->finder->findUser(['Login' => $this->Login])->one();
             /**
              * Generate password
              */
             $hash = Yii::$app->security->generatePasswordHash($this->Password);
             ////$this->Password = $this->Password . ':' . $hash;
             ////list($password, $hash) = explode(':', $this->Password);
             //                if ($this->user !== null && Yii::$app->getSecurity()->validatePassword($this->Password, $hash) ) {
             //                    $this->user->updateAttributes(['Password' => $hash]);
             //                    echo $this->Password . ':' . $hash. ' OK  ';
             //                }
             //                exit;
         }
         if ($this->user === null) {
             if (CardRecord::check($this->Login)) {
                 $card = CardRecord::findCard($this->Login);
                 if ($card !== null && $card->person) {
                     //                    $this->user = $card->person->ServiceCard ? $card->person : null;
                     $this->user = $card->person;
                     return true;
                 }
             }
             $this->addError('Login', \Yii::t('user', 'Invalid login or password'));
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }