/** * @param array $params * - emailEnabled: (bool) must be true for the option to email passwords to be present * - newPasswordExpiry: (int) expiraton time of temporary passwords, in seconds * - passwordReminderResendTime: (int) cooldown period in hours until a password reminder can * be sent to the same user again, */ public function __construct($params = []) { parent::__construct($params); if (isset($params['emailEnabled'])) { $this->emailEnabled = (bool) $params['emailEnabled']; } if (isset($params['newPasswordExpiry'])) { $this->newPasswordExpiry = (int) $params['newPasswordExpiry']; } if (isset($params['passwordReminderResendTime'])) { $this->passwordReminderResendTime = $params['passwordReminderResendTime']; } }
/** * @param AuthPlugin $auth AuthPlugin to wrap * @param string|null $requestType Class name of the * PasswordAuthenticationRequest to use. If $auth->domainList() returns * more than one domain, this must be a PasswordDomainAuthenticationRequest. */ public function __construct(AuthPlugin $auth, $requestType = null) { parent::__construct(); if ($auth instanceof AuthManagerAuthPlugin) { throw new \InvalidArgumentException('Trying to wrap AuthManagerAuthPlugin in AuthPluginPrimaryAuthenticationProvider ' . 'makes no sense.'); } $need = count($auth->domainList()) > 1 ? PasswordDomainAuthenticationRequest::class : PasswordAuthenticationRequest::class; if ($requestType === null) { $requestType = $need; } elseif ($requestType !== $need && !is_subclass_of($requestType, $need)) { throw new \InvalidArgumentException("{$requestType} is not a {$need}"); } $this->auth = $auth; $this->requestType = $requestType; $this->hasDomain = $requestType === PasswordDomainAuthenticationRequest::class || is_subclass_of($requestType, PasswordDomainAuthenticationRequest::class); $this->authoritative = $auth->strict(); // Registering hooks from core is unusual, but is needed here to be // able to call the AuthPlugin methods those hooks replace. \Hooks::register('UserSaveSettings', [$this, 'onUserSaveSettings']); \Hooks::register('UserGroupsChanged', [$this, 'onUserGroupsChanged']); \Hooks::register('UserLoggedIn', [$this, 'onUserLoggedIn']); \Hooks::register('LocalUserCreated', [$this, 'onLocalUserCreated']); }
/** * @param array $params Settings * - loginOnly: If true, the local passwords are for legacy logins only: * the local password will be invalidated when authentication is changed * and new users will not have a valid local password set. */ public function __construct($params = []) { parent::__construct($params); $this->loginOnly = !empty($params['loginOnly']); }