mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 20:11:46 +02:00
Fix issue processwire/processwire-issues#1534
This commit is contained in:
@@ -1006,23 +1006,43 @@ class ProcessLogin extends Process implements ConfigurableModule {
|
|||||||
|
|
||||||
/** @var Modules $modules */
|
/** @var Modules $modules */
|
||||||
$modules = $this->wire('modules');
|
$modules = $this->wire('modules');
|
||||||
|
|
||||||
/** @var InputfieldRadios $f */
|
/** @var InputfieldRadios $f */
|
||||||
$f = $modules->get('InputfieldRadios');
|
$f = $modules->get('InputfieldRadios');
|
||||||
|
|
||||||
|
$emailAllow = true;
|
||||||
|
$emailField = $this->fields->get($this->emailField); /** @var Field $field */
|
||||||
|
$emailAttrs = array();
|
||||||
|
$emailLabel = $this->_('Email address');
|
||||||
|
$emailNotes = array();
|
||||||
|
|
||||||
|
if($emailField && ((int) $this->allowEmail) !== 1) {
|
||||||
|
if(!$emailField->hasFlag(Field::flagUnique)) {
|
||||||
|
$emailAllow = false;
|
||||||
|
$emailNotes[] = sprintf(
|
||||||
|
$this->_('You must [enable the “unique” setting](%s) for your email field'),
|
||||||
|
$emailField->editUrl('flagUnique')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$role = $this->wire()->roles->get($this->wire()->config->superUserRolePageID);
|
||||||
|
if($this->wire()->users->count("roles=$role, email=''") > 0) {
|
||||||
|
$emailAllow = false;
|
||||||
|
$emailNotes[] = $this->_('All superusers must have an email address defined');
|
||||||
|
}
|
||||||
|
if(!$emailAllow) {
|
||||||
|
$emailAttrs['disabled'] = 'disabled';
|
||||||
|
$emailLabel .= ' - ' . $this->_('See notes below to enable');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$f->attr('name', 'allowEmail');
|
$f->attr('name', 'allowEmail');
|
||||||
$f->label = $this->_('Login type');
|
$f->label = $this->_('Login type');
|
||||||
$f->addOption(0, $this->_('User name'));
|
$f->addOption(0, $this->_('User name'));
|
||||||
$f->addOption(1, $this->_('Email address'));
|
$f->addOption(1, $emailLabel, $emailAttrs);
|
||||||
$f->addOption(2, $this->_('Either'));
|
$f->addOption(2, $this->_('Either'), $emailAttrs);
|
||||||
$f->icon = 'sign-in';
|
$f->icon = 'sign-in';
|
||||||
$f->val((int) $this->allowEmail);
|
$f->val((int) $this->allowEmail);
|
||||||
$emailField = $this->fields->get($this->emailField); /** @var Field $field */
|
if(count($emailNotes)) $f->notes = $this->_('To use login-by-email: ') . implode(', ', $emailNotes);
|
||||||
if($emailField && !$emailField->hasFlag(Field::flagUnique)) {
|
|
||||||
$f->notes = sprintf(
|
|
||||||
$this->_('To use email login, you must [enable the “unique” setting](%s) for your email field.'),
|
|
||||||
$emailField->editUrl('flagUnique')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$inputfields->add($f);
|
$inputfields->add($f);
|
||||||
$inputfields->add($this->getTfaConfigInputfields());
|
$inputfields->add($this->getTfaConfigInputfields());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user