SAAS-781 - password reset
This commit is contained in:
parent
abdc94ccc3
commit
5c4803ddf2
8 changed files with 28 additions and 220 deletions
|
@ -140,9 +140,6 @@ class LoginController extends Zend_Controller_Action
|
||||||
|
|
||||||
Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', $stationLocale));
|
Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', $stationLocale));
|
||||||
|
|
||||||
// if (!Application_Model_Preference::GetEnableSystemEmail()) {
|
|
||||||
// $this->_redirect('login');
|
|
||||||
// } else {
|
|
||||||
//uses separate layout without a navigation.
|
//uses separate layout without a navigation.
|
||||||
$this->_helper->layout->setLayout('login');
|
$this->_helper->layout->setLayout('login');
|
||||||
|
|
||||||
|
@ -150,16 +147,16 @@ class LoginController extends Zend_Controller_Action
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||||
if (is_null($form->username->getValue()) || $form->username->getValue() == '') {
|
$query = CcSubjsQuery::create();
|
||||||
$user = CcSubjsQuery::create()
|
if (empty($form->username->getValue())) {
|
||||||
->filterByDbEmail($form->email->getValue())
|
$query->filterByDbEmail($form->email->getValue());
|
||||||
->findOne();
|
} else if (empty($form->email->getValue())) {
|
||||||
|
$query->filterByDbLogin($form->username->getValue());
|
||||||
} else {
|
} else {
|
||||||
$user = CcSubjsQuery::create()
|
$query->filterByDbEmail($form->email->getValue())
|
||||||
->filterByDbEmail($form->email->getValue())
|
->filterByDbLogin($form->username->getValue());
|
||||||
->filterByDbLogin($form->username->getValue())
|
|
||||||
->findOne();
|
|
||||||
}
|
}
|
||||||
|
$user = $query->findOne();
|
||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$auth = new Application_Model_Auth();
|
$auth = new Application_Model_Auth();
|
||||||
|
@ -168,15 +165,14 @@ class LoginController extends Zend_Controller_Action
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$this->_helper->redirector('password-restore-after', 'login');
|
$this->_helper->redirector('password-restore-after', 'login');
|
||||||
} else {
|
} else {
|
||||||
$form->email->addError($this->view->translate(_("Email could not be sent. Check your mail server settings and ensure it has been configured properly.")));
|
$form->email->addError($this->view->translate(_("There was a problem sending the recovery email.")));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$form->email->addError($this->view->translate(_("Given email not found.")));
|
$form->email->addError($this->view->translate(_("We couldn't find the email you entered - you can also try <a href='https://account.sourcefabric.com/pwreset.php'>here</a>.")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function passwordRestoreAfterAction()
|
public function passwordRestoreAfterAction()
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
<?php
|
|
||||||
require_once 'customvalidators/ConditionalNotEmpty.php';
|
|
||||||
|
|
||||||
class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
|
||||||
{
|
|
||||||
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->setDecorators(array(
|
|
||||||
array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml'))
|
|
||||||
));
|
|
||||||
|
|
||||||
// Enable system emails
|
|
||||||
$this->addElement('checkbox', 'enableSystemEmail', array(
|
|
||||||
'label' => _('Enable System Emails (Password Reset)'),
|
|
||||||
'required' => false,
|
|
||||||
'value' => Application_Model_Preference::GetEnableSystemEmail(),
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('text', 'systemEmail', array(
|
|
||||||
'class' => 'input_text',
|
|
||||||
'label' => _("Reset Password 'From' Email"),
|
|
||||||
'value' => Application_Model_Preference::GetSystemEmail(),
|
|
||||||
'readonly' => true,
|
|
||||||
'decorators' => array('viewHelper')
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('checkbox', 'configureMailServer', array(
|
|
||||||
'label' => _('Configure Mail Server'),
|
|
||||||
'required' => false,
|
|
||||||
'value' => Application_Model_Preference::GetMailServerConfigured(),
|
|
||||||
'decorators' => array (
|
|
||||||
'viewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('checkbox', 'msRequiresAuth', array(
|
|
||||||
'label' => _('Requires Authentication'),
|
|
||||||
'required' => false,
|
|
||||||
'value' => Application_Model_Preference::GetMailServerRequiresAuth(),
|
|
||||||
'decorators' => array(
|
|
||||||
'viewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('text', 'mailServer', array(
|
|
||||||
'class' => 'input_text',
|
|
||||||
'label' => _('Mail Server'),
|
|
||||||
'value' => Application_Model_Preference::GetMailServer(),
|
|
||||||
'readonly' => true,
|
|
||||||
'decorators' => array('viewHelper'),
|
|
||||||
'allowEmpty' => false,
|
|
||||||
'validators' => array(
|
|
||||||
new ConditionalNotEmpty(array(
|
|
||||||
'configureMailServer' => '1'
|
|
||||||
))
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('text', 'email', array(
|
|
||||||
'class' => 'input_text',
|
|
||||||
'label' => _('Email Address'),
|
|
||||||
'value' => Application_Model_Preference::GetMailServerEmailAddress(),
|
|
||||||
'readonly' => true,
|
|
||||||
'decorators' => array('viewHelper'),
|
|
||||||
'allowEmpty' => false,
|
|
||||||
'validators' => array(
|
|
||||||
new ConditionalNotEmpty(array(
|
|
||||||
'configureMailServer' => '1',
|
|
||||||
'msRequiresAuth' => '1'
|
|
||||||
))
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addElement('password', 'ms_password', array(
|
|
||||||
'class' => 'input_text',
|
|
||||||
'label' => _('Password'),
|
|
||||||
'value' => Application_Model_Preference::GetMailServerPassword(),
|
|
||||||
'readonly' => true,
|
|
||||||
'decorators' => array('viewHelper'),
|
|
||||||
'allowEmpty' => false,
|
|
||||||
'validators' => array(
|
|
||||||
new ConditionalNotEmpty(array(
|
|
||||||
'configureMailServer' => '1',
|
|
||||||
'msRequiresAuth' => '1'
|
|
||||||
))
|
|
||||||
),
|
|
||||||
'renderPassword' => true
|
|
||||||
));
|
|
||||||
|
|
||||||
$port = new Zend_Form_Element_Text('port');
|
|
||||||
$port->class = 'input_text';
|
|
||||||
$port->setRequired(false)
|
|
||||||
->setValue(Application_Model_Preference::GetMailServerPort())
|
|
||||||
->setLabel(_('Port'))
|
|
||||||
->setAttrib('readonly', true)
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
|
|
||||||
$this->addElement($port);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ class Application_Form_PasswordRestore extends Zend_Form
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('text', 'email', array(
|
$this->addElement('text', 'email', array(
|
||||||
'label' => _('E-mail'),
|
'label' => _('Email'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'filters' => array(
|
'filters' => array(
|
||||||
'stringTrim',
|
'stringTrim',
|
||||||
|
@ -43,7 +43,7 @@ class Application_Form_PasswordRestore extends Zend_Form
|
||||||
|
|
||||||
$cancel = new Zend_Form_Element_Button("cancel");
|
$cancel = new Zend_Form_Element_Button("cancel");
|
||||||
$cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center';
|
$cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center';
|
||||||
$cancel->setLabel(_("Cancel"))
|
$cancel->setLabel(_("Return to login"))
|
||||||
->setIgnore(True)
|
->setIgnore(True)
|
||||||
->setAttrib('onclick', 'redirectToLogin();')
|
->setAttrib('onclick', 'redirectToLogin();')
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
|
|
|
@ -34,9 +34,7 @@ class Application_Model_Auth
|
||||||
$message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}";
|
$message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}";
|
||||||
|
|
||||||
$str = sprintf(_('%s Password Reset'), PRODUCT_NAME);
|
$str = sprintf(_('%s Password Reset'), PRODUCT_NAME);
|
||||||
$success = Application_Model_Email::send($str, $message, $user->getDbEmail());
|
return Application_Model_Email::send($str, $message, $user->getDbEmail());
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidateTokens($user, $action)
|
public function invalidateTokens($user, $action)
|
||||||
|
|
|
@ -2,18 +2,20 @@
|
||||||
|
|
||||||
class Application_Model_Email
|
class Application_Model_Email
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send email
|
* Send email
|
||||||
*
|
*
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param mixed $tos
|
* @param mixed $to
|
||||||
* @return void
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function send($subject, $message, $tos, $from = null)
|
public static function send($subject, $message, $to) {
|
||||||
{
|
|
||||||
|
|
||||||
return mail($tos, $subject, $message);
|
$headers = 'From: Airtime <noreply@account.sourcefabric.com>';
|
||||||
|
return mail($to, $subject, $message, $headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1161,87 +1161,6 @@ class Application_Model_Preference
|
||||||
{
|
{
|
||||||
return self::getValue("auto_switch");
|
return self::getValue("auto_switch");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetEnableSystemEmail($upload)
|
|
||||||
{
|
|
||||||
self::setValue("enable_system_email", $upload);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetEnableSystemEmail()
|
|
||||||
{
|
|
||||||
$v = self::getValue("enable_system_email");
|
|
||||||
return ($v === "") ? 0 : $v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetSystemEmail($value)
|
|
||||||
{
|
|
||||||
self::setValue("system_email", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetSystemEmail()
|
|
||||||
{
|
|
||||||
return self::getValue("system_email");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServerConfigured($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server_configured", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServerConfigured()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server_configured");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServer($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServer()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServerEmailAddress($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server_email_address", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServerEmailAddress()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server_email_address");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServerPassword($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server_password", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServerPassword()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server_password");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServerPort($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server_port", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServerPort()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server_port");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetMailServerRequiresAuth($value)
|
|
||||||
{
|
|
||||||
self::setValue("mail_server_requires_auth", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetMailServerRequiresAuth()
|
|
||||||
{
|
|
||||||
return self::getValue("mail_server_requires_auth");
|
|
||||||
}
|
|
||||||
/* User specific preferences end */
|
/* User specific preferences end */
|
||||||
|
|
||||||
public static function ShouldShowPopUp()
|
public static function ShouldShowPopUp()
|
||||||
|
|
|
@ -30,17 +30,15 @@
|
||||||
|
|
||||||
<?php echo $this->element->getElement('csrf') ?>
|
<?php echo $this->element->getElement('csrf') ?>
|
||||||
|
|
||||||
<!-- --><?php //if (Application_Model_Preference::GetEnableSystemEmail()): ?>
|
|
||||||
<dt id="reset-label" class="hidden"> </dt>
|
|
||||||
<dd id="reset-element" class="text-right">
|
|
||||||
<a href="<?php echo $this->baseUrl('login/password-restore'); ?>" class="link reset"><?php echo _("Reset password") ?></a>
|
|
||||||
</dd>
|
|
||||||
<!-- --><?php //endif; ?>
|
|
||||||
<?php echo $this->element->getElement('captcha') ?>
|
<?php echo $this->element->getElement('captcha') ?>
|
||||||
<dt id="submit-label"> </dt>
|
<dt id="submit-label"> </dt>
|
||||||
<dd id="submit-element">
|
<dd id="submit-element">
|
||||||
<?php echo $this->element->getElement('submit') ?>
|
<?php echo $this->element->getElement('submit') ?>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt id="reset-label" class="hidden"> </dt>
|
||||||
|
<dd id="reset-element" class="text-right">
|
||||||
|
<a href="<?php echo $this->baseUrl('login/password-restore'); ?>" class="link reset"><?php echo _("Forgot your password?") ?></a>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
<div id="login" class="login-content clearfix">
|
<div id="login" class="login-content clearfix">
|
||||||
<p class="light">
|
<p class="light">
|
||||||
<?php echo _("Please enter your account e-mail address. You will receive a link to create a new password via e-mail.")?>
|
<?php echo _("Enter your account e-mail address or your username (or both, if you have multiple accounts
|
||||||
|
using the same email address), and we'll send you a link to reset your password.")?>
|
||||||
</p>
|
</p>
|
||||||
<?php echo $this->form; ?>
|
<?php echo $this->form; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue