Yii::t('common/site', 'Username'), 'password' => Yii::t('common/site', 'Password'), ]; } /** * Validates the password. * This method serves as the inline validation for password. * * @param string $attribute the attribute currently being validated * @param array $params the additional name-value pairs given in the rule * @throws \yii\base\InvalidConfigException */ public function validateCardNumber($attribute, $params) { if ($this->hasErrors()) { /** @var \common\models\Customer $user */ throw new BadRequestHttpException(); } $customer = $this->getCustomer(); } /** * Finds user by [[username]] * * @return Customer|null|ActiveRecord */ public function getCustomer() { if ($this->customer === null) { $mobileDeviceManager = new MobileDeviceManager(); $mobileDevice = $mobileDeviceManager->loginOrCreate($this->cardNumber, $this->deviceId, $this->deviceName); /** @var Customer */ $this->customer = Customer::find()->andWhere([ 'id_customer_card' => $mobileDevice->id_card ])->one(); if ($this->customer == null) { throw new NotFoundHttpException(); } } return $this->customer; } }