1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-24 15:23:11 +02:00

Minor tweaks in WireHooks, ProcessForgotPassword and SessionLoginThrottle

This commit is contained in:
Ryan Cramer
2019-12-20 15:06:57 -05:00
parent a11403b913
commit 9a9bdb464a
3 changed files with 26 additions and 7 deletions

View File

@@ -25,6 +25,7 @@
* @property array $confirmFields Extra field values to confirm values before accepting password change, optional. (default=['email'])
* @property array $allowRoles Only allow password reset for these roles, optional. (default=[])
* @property array $blockRoles Block these roles, optional. (default=[])
* @property string $wireMailer WireMail module name to use or omit for system default. Since 3.0.148.
*
* @method string renderEmailBody($url, $code, $html) Render the password reset email body, and $url should appear in that email body.
* @method string renderErrorEmailBody($error) Render error email body
@@ -95,6 +96,7 @@ class ProcessForgotPassword extends Process implements ConfigurableModule {
$this->set('confirmFields', array());
$this->set('allowRoles', array());
$this->set('blockRoles', array());
$this->set('wireMailer', '');
$emailField = $this->wire('fields')->get('email');
if($emailField) $this->set('confirmFields', array("email:$emailField->id"));
@@ -335,9 +337,10 @@ class ProcessForgotPassword extends Process implements ConfigurableModule {
$body = $this->renderEmailBody($url, $verify, false);
$bodyHTML = $this->renderEmailBody($url, $verify, true);
// if(self::debug) $this->message($bodyHTML, Notice::allowMarkup);
$email = null;
if($this->wireMailer) $email = $this->wire('mail')->new(array('module' => $this->wireMailer));
if(!$email) $email = $this->wire('mail')->new();
$email = $this->wire('mail')->new();
$email->to($user->email)->from($this->getEmailFrom());
$email->subject($this->emailSubject)->body($body)->bodyHTML($bodyHTML);
@@ -518,7 +521,7 @@ class ProcessForgotPassword extends Process implements ConfigurableModule {
$f->attr('name', $field->name);
$f->collapsed = Inputfield::collapsedNever;
$f->columnWidth = 100;
$f->notes = $this->_('Resetting password also requires that you confirm the correct value of this field.');
$f->description = $this->_('Resetting password also requires that you confirm the correct value of this field.');
$form->add($f);
$confirmFields[$key] = $field->name;
}

View File

@@ -147,7 +147,7 @@ class SessionLoginThrottle extends WireData implements Module, ConfigurableModul
if($this->wire('process') == 'ProcessLogin') {
parent::error($error);
} else {
throw new WireException($error); // ensures the error can't be missed in unknown API usage
throw new SessionLoginThrottleException($error); // ensures the error can't be missed in unknown API usage
}
} else {
$allowed = true;
@@ -268,3 +268,9 @@ class SessionLoginThrottle extends WireData implements Module, ConfigurableModul
}
}
/**
* Exception thrown when login overflow occurs and throttle is active
*
*/
class SessionLoginThrottleException extends WireException { }