HttpBasicAuth::className(), 'auth' => [$this, 'auth'] ]; return $behaviors; } public function auth($username, $password) { try { $user = User::findOne(['username' => $username]); if ( !isset($user ) ){ \Yii::error("User not found: ".$username); return null; } if ($user->validatePassword($password)) { return $user; } } catch (\Exception $e) { \Yii::error("Failed to load user $username: " . $e->getMessage()); } \Yii::error("User not found: ".$username); return null; } }