Clean up and bugfixes for password reset (SAAS-1009)

This commit is contained in:
Albert Santoni 2015-08-07 13:57:42 -04:00
parent ea86675d07
commit ea2a6b3f68
9 changed files with 105 additions and 72 deletions

View File

@ -9,6 +9,7 @@ define('COMPANY_NAME' , 'Sourcefabric');
define('COMPANY_SUFFIX' , 'z.ú.');
define('COMPANY_SITE' , 'Sourcefabric.org');
define('COMPANY_SITE_URL' , 'http://sourcefabric.org/');
define('SUPPORT_EMAIL_ADDRESS', "help@sourcefabric.org");
define('HELP_URL' , 'http://help.sourcefabric.org/');
define('FAQ_URL' , 'https://sourcefabricberlin.zendesk.com/hc/en-us/sections/200994309-Airtime-FAQ');

View File

@ -38,11 +38,9 @@ class LoginController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/login/login.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$form = new Application_Form_Login();
$message = _("Please enter your user name and password");
$message = _("Please enter your username and password.");
if ($request->isPost()) {
// if the post contains recaptcha field, which means form had recaptcha field.
@ -132,12 +130,12 @@ class LoginController extends Zend_Controller_Action
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/login/password-restore.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl . 'js/airtime/login/password-restore.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
$request = $this->getRequest();
$stationLocale = Application_Model_Preference::GetDefaultLocale();
Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', $stationLocale));
//uses separate layout without a navigation.
@ -146,17 +144,18 @@ class LoginController extends Zend_Controller_Action
$form = new Application_Form_PasswordRestore();
$request = $this->getRequest();
if ($request->isPost() && $form->isValid($request->getPost())) {
$query = CcSubjsQuery::create();
if (empty($form->username->getValue())) {
$query->filterByDbEmail($form->email->getValue());
} else if (empty($form->email->getValue())) {
$query->filterByDbLogin($form->username->getValue());
} else {
$query->filterByDbEmail($form->email->getValue())
->filterByDbLogin($form->username->getValue());
}
$user = $query->findOne();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$query = CcSubjsQuery::create();
if (empty($form->username->getValue())) {
$query->filterByDbEmail($form->email->getValue());
} else if (empty($form->email->getValue())) {
$query->filterByDbLogin($form->username->getValue());
} else {
$query->filterByDbEmail($form->email->getValue())
->filterByDbLogin($form->username->getValue());
}
$user = $query->findOne();
if (!empty($user)) {
$auth = new Application_Model_Auth();
@ -171,8 +170,9 @@ class LoginController extends Zend_Controller_Action
$form->email->addError($this->view->translate(_("There was a problem sending the recovery email.")));
}
} else {
$form->email->addError($this->view->translate(_("We couldn't find the email you entered - you can also try <a href='".WHMCS_PASSWORD_RESET_URL."'>here</a>.")));
$form->email->addError($this->view->translate(sprintf(_pro("We couldn't find the email you entered - you can also try <a href=\"%s\">here</a>."), WHMCS_PASSWORD_RESET_URL)));
}
}
$this->view->form = $form;
}

View File

@ -33,7 +33,7 @@ class Application_Form_PasswordRestore extends Zend_Form
));
$this->addElement('submit', 'submit', array(
'label' => _('Restore password'),
'label' => _('Reset password'),
'ignore' => true,
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
'decorators' => array(
@ -41,12 +41,14 @@ class Application_Form_PasswordRestore extends Zend_Form
)
));
/*
$cancel = new Zend_Form_Element_Button("cancel");
$cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center';
$cancel->setLabel(_("Return to login"))
$cancel->setLabel(_("Back"))
->setIgnore(True)
->setAttrib('onclick', 'redirectToLogin();')
->setAttrib('onclick', 'window.location = ' . Zend_Controller_Front::getInstance()->getBaseUrl('login'))
->setDecorators(array('ViewHelper'));
$this->addElement($cancel);
*/
}
}

View File

@ -30,10 +30,12 @@ class Application_Model_Auth
$e_link_port = $_SERVER['SERVER_PORT'];
$e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change');
$message = sprintf(_("Hi %s, \n\nClick this link to reset your password: "), $user->getDbLogin());
$message = sprintf(_("Hi %s, \n\nPlease click this link to reset your password: "), $user->getDbLogin());
$message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}";
$message .= sprintf(_pro("\n\nIf you have any problems, please contact our support team: %s"), SUPPORT_EMAIL_ADDRESS);
$message .= sprintf(_pro("\n\nThank you, The %s Team"), SAAS_PRODUCT_BRANDING_NAME);
$str = sprintf(_('%s Password Reset'), PRODUCT_NAME);
$str = sprintf(_('%s Password Reset'), SAAS_PRODUCT_BRANDING_NAME);
return Application_Model_Email::send($str, $message, $user->getDbEmail());
}

View File

@ -13,7 +13,7 @@ class Application_Model_Email
*/
public static function send($subject, $message, $to) {
$headers = 'From: Airtime <noreply@account.sourcefabric.com>';
$headers = sprintf('From: %s <noreply@account.sourcefabric.com>', SAAS_PRODUCT_BRANDING_NAME);
return mail($to, $subject, $message, $headers);
}

View File

@ -1,36 +1,54 @@
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<dt id="username-label">
<dt id="email-label">
<label for="email" class="required">
<?php echo $this->element->getElement('email')->getLabel() ?>
</label>
</dt>
<dd id="email-element">
<?php echo $this->element->getElement('email') ?>
</dd>
<?php if ($this->element->getElement('email')->hasErrors()): ?>
<ul class='errors'>
<?php foreach ($this->element->getElement('email')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<fieldset>
<legend>Station Owners</legend>
<p>
<?php echo(sprintf(_pro("If you are the primary owner of this station, <a href=\"%s\">please reset your password here</a>."), WHMCS_PASSWORD_RESET_URL)); ?>
</p>
<label for="username" class="required">
<?php echo $this->element->getElement('username')->getLabel() ?>
</label>
</dt>
<dd id="username-element">
<?php echo $this->element->getElement('username') ?>
</dd>
</fieldset>
<fieldset>
<legend>DJs, Program Managers, and Others</legend>
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<p>Please enter both your username and email address.</p>
<dt id="username-label">
<label for="username" class="required">
<?php echo $this->element->getElement('username')->getLabel() ?>
</label>
</dt>
<dd id="username-element">
<?php echo $this->element->getElement('username') ?>
</dd>
</dt>
<dt id="email-label">
<label for="email" class="required">
<?php echo $this->element->getElement('email')->getLabel() ?>
</label>
</dt>
<dd id="email-element">
<?php echo $this->element->getElement('email') ?>
</dd>
<?php if ($this->element->getElement('email')->hasErrors()): ?>
<ul class='errors'>
<?php foreach ($this->element->getElement('email')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<dt id="submit-label">&nbsp;</dt>
<dd id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</dd>
<dd id="cancel-element">
<a href="<?php echo($this->baseUrl('login')); ?>">
<button name="cancel" type="button" class="ui-button ui-widget ui-state-default ui-button-text-only center"><?php echo(_("Back")); ?></button>
</a>
</dd>
</dl>
</form>
</fieldset>
<dt id="submit-label">&nbsp;</dt>
<dd id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</dd>
<dd id="cancel-element">
<?php echo $this->element->getElement('cancel') ?>
</dd>
</dl>
</form>

View File

@ -1,12 +1,8 @@
<div class="login_box">
<div class="logobox">&nbsp;</div>
<h2><?php echo _("Reset password") ?></h2>
<h2><?php echo _("Password Reset") ?></h2>
<div id="login" class="login-content clearfix">
<p class="light">
<?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>
<?php echo $this->form; ?>
</div>
</div>

View File

@ -21,6 +21,19 @@ html, body {
text-align:center;
}
#login-page fieldset
{
padding: 10px;
border: 1px solid #555;
margin-bottom: 10px;
}
#login-page legend {
font-weight: bold;
color: #919191;
}
h2 {
color: #000000;
font-size: 2.1em;
@ -1070,7 +1083,7 @@ input[type="checkbox"] {
margin:0;
padding:8px 0 16px 0;
font-size:12px;
color:#717171;
color: #919191;
text-align:left;
}
.logobox {
@ -1195,13 +1208,17 @@ input[type="checkbox"] {
.login-content .text-right, .text-right {
text-align:right;
}
.login-content .link {
.login-content a {
color:#FF5D1A;
text-decoration:none;
}
.login-content .link:hover {
text-decoration:underline;
}
}
.login-content a:hover {
text-decoration:underline;
}
.login-content .errors a {
color: #ff1c13;
}
/*---//////////////////// END LOGIN ////////////////////---*/

View File

@ -1,3 +0,0 @@
function redirectToLogin(){
window.location = baseUrl+"Login"
}