diff --git a/src/events/UserQueryCriteria.php b/src/events/UserQueryCriteria.php new file mode 100644 index 0000000..102c6f4 --- /dev/null +++ b/src/events/UserQueryCriteria.php @@ -0,0 +1,17 @@ + UserElement::find(), + 'usernameOrEmail' => $usernameOrEmail, + 'archived' => $archived, + ]); + + if (Event::hasHandlers(self::class, self::EVENT_GET_CUSTOM_USER_CRITERIA)) { + Event::trigger( + self::class, + self::EVENT_GET_CUSTOM_USER_CRITERIA, + $event + ); + } - return UserElement::find() + return ($event->applyDefaultCriteria ? $event->userQuery ->where( [ 'or', - ['username' => $usernameOrEmail], - ['email' => $usernameOrEmail], + ['username' => $event->usernameOrEmail], + ['email' => $event->usernameOrEmail], ] ) ->status(null) - ->archived($archived) - ->one(); + ->archived($event->archived) : $event->userQuery)->one(); } private function getAttributeValue($attributeValue)