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:
@@ -1009,20 +1009,40 @@ class ProcessLogin extends Process implements ConfigurableModule {
|
||||
|
||||
/** @var InputfieldRadios $f */
|
||||
$f = $modules->get('InputfieldRadios');
|
||||
$f->attr('name', 'allowEmail');
|
||||
$f->label = $this->_('Login type');
|
||||
$f->addOption(0, $this->_('User name'));
|
||||
$f->addOption(1, $this->_('Email address'));
|
||||
$f->addOption(2, $this->_('Either'));
|
||||
$f->icon = 'sign-in';
|
||||
$f->val((int) $this->allowEmail);
|
||||
|
||||
$emailAllow = true;
|
||||
$emailField = $this->fields->get($this->emailField); /** @var Field $field */
|
||||
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.'),
|
||||
$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->label = $this->_('Login type');
|
||||
$f->addOption(0, $this->_('User name'));
|
||||
$f->addOption(1, $emailLabel, $emailAttrs);
|
||||
$f->addOption(2, $this->_('Either'), $emailAttrs);
|
||||
$f->icon = 'sign-in';
|
||||
$f->val((int) $this->allowEmail);
|
||||
if(count($emailNotes)) $f->notes = $this->_('To use login-by-email: ') . implode(', ', $emailNotes);
|
||||
$inputfields->add($f);
|
||||
$inputfields->add($this->getTfaConfigInputfields());
|
||||
}
|
||||
|
Reference in New Issue
Block a user