public function auth($username, $password) { $user = \app\models\User2::findOne(['username' => $username, 'status' => 10]); if (!$user) { throw new UnauthorizedHttpException('You are requesting with invalid username or password.'); } if ($user->validatePassword($password)) { return $user; } else { return null; } }
/** * @return \yii\db\ActiveQuery */ public function getAuthor() { return $this->hasOne(User2::className(), ['id' => 'author_id']); }