Password Reset Validation, Removal of unnessary files, Service display updates

This commit is contained in:
Deon George 2013-06-06 00:03:55 +10:00
parent 0efd99f194
commit 66ea9babf4
12 changed files with 94 additions and 163 deletions

View File

@ -65,7 +65,7 @@ class Config extends Kohana_Config {
}
public static function date($date) {
return is_null($date) ? NULL : date(Company::instance()->date_format(),$date);
return is_null($date) ? ' ' : date(Company::instance()->date_format(),$date);
}
/**

View File

@ -40,7 +40,7 @@ class Controller_Login extends lnApp_Controller_Login {
// If the username is correct, create a method token
if (! empty($_POST['username']) AND ($ao=ORM::factory('Account',array('username'=>$_POST['username']))) AND $ao->loaded()) {
$mmto = ORM::factory('Module_Method_Token')
->method(array('account','user_resetpassword'))
->method(array('account','user:resetpassword'))
->account($ao)
->uses(2)
->expire(time()+$token_expire*60);

View File

@ -1,23 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB User Main home page controller
*
* @package OSB
* @category Controllers/Affiliate
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_TemplateDefault_Affiliate extends Controller_TemplateDefault_User {
public function after() {
SystemMessage::add(array(
'title'=>'Retire this class extension',
'type'=>'info',
'body'=>__METHOD__,
));
return parent::after();
}
}
?>

View File

@ -56,48 +56,73 @@ class Controller_User_Account extends Controller_Account {
}
public function action_resetpassword() {
// @todo Fix this next logic, since matches_ifset is not being called when the value is on the form, but empty
if (empty($_POST['password_confirm']))
$_POST['password_confirm'] = ' ';
if ($this->request->post()) {
$validation = Validation::factory($this->request->post())
->rule('password','not_empty')
->rule('password','min_length',array(':value',6))
->rule('password_confirm','matches',array(':validation',':field','password'));
// Store our new values
$this->ao->values($_POST);
$this->ao->values($this->request->post());
if (! $validation->check())
SystemMessage::factory()
->title(_('Record NOT updated'))
->type('error')
->body(_('Your password didnt pass validation.'));
// Run validation and save
if ($this->ao->changed())
if ($this->ao->check()) {
elseif ($this->ao->changed())
if ($this->ao->save()) {
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your account record has been updated.'));
$this->ao->save();
// Log the password reset
$this->ao->log('Password reset');
HTTP::redirect('login');
} else {
// @todo Need to check that this still works with the new bootstrap theming
$output = '';
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
if ($output)
$output = sprintf('<ul>%s</ul>',$output);
SystemMessage::factory()
->title(_('Record NOT updated'))
->type('error')
->body(_('Your updates didnt pass validation.').'<br/>'.$output);
}
}
// @todo To add JS password validation (minimum length and both values equal)
if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure())
Script::factory()
->type('src')
->data('media/js/jquery/jquery.validate-1.11.1.min.js');
else
Script::factory()
->type('src')
->data('http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js');
Script::factory()
->type('stdin')
->data('
$("#reset").validate({
wrapper: "div",
errorElement: "span",
rules: {
password_confirm: {
equalTo: "input[name=password]",
},
},
highlight: function(element) {
$(element).parents(".control-group").removeClass("success").addClass("error");
},
success: function(element) {
$(element).parents(".control-group").removeClass("error").addClass("success");
},
errorPlacement: function(error, element) {
error.appendTo(element.parents(".controls"));
}
});
');
Block::factory()
->title(sprintf('Password Reset: %s',$this->ao->accnum()))
->title_icon('icon-cog')
->id('reset')
->type('form-horizontal')
->body(View::factory('account/user/resetpassword')->set('o',$this->ao));
}

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Affiliate
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Affiliate extends ORM_OSB {
}
?>

View File

@ -17,34 +17,15 @@ class Model_Auth_UserDefault extends Model_Auth_User {
array('min_length', array(':value', 4)),
array('max_length', array(':value', 32)),
),
'password' => array(
array('not_empty'),
array('min_length', array(':value', 5)),
array('max_length', array(':value', 32)),
),
'email' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 127)),
array('email'),
),
// @todo To test
'password_confirm' => array(
array('matches_ifset', array(':validation', 'password', 'password_confirm')),
),
);
}
// Validation callbacks
// @todo _callbacks no longer used
protected $_callbacks = array(
'username' => array('username_available'),
'email' => array('email_available'),
);
// Columns to ignore
protected $_ignored_columns = array('password_confirm');
/**
* Complete our login
*

View File

@ -1,18 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's Response
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Response extends Kohana_Response {
// Append to the body.
public function bodyadd($content) {
$this->_body .= (string) $content;
}
}
?>

View File

@ -1,27 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Array and variable validation.
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Valid extends Kohana_Valid {
/**
* Checks if a field matches the value of another field, if it is set.
* Field is ignored if it is blank.
*
* @param array array of values
* @param string field name
* @param string field name to match
* @return boolean
*/
public static function matches_ifset($array, $field, $match)
{
return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE;
}
}
?>

View File

@ -1,18 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports affiliates
*
* @package Affiliate
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Affiliate extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
'host_server_affiliate'=>array('far_key'=>'affiliate_id','foreign_key'=>'id'),
);
}
?>

View File

@ -90,7 +90,7 @@ class Model_Service extends ORM_OSB {
$expire = (is_null($plugin=$this->plugin()) ? NULL : $plugin->expire());
// If $expire is NULL, we'll use the next invoice date
$expire = is_null($expire) ? $this->date_next_invoice-86400 : $expire;
$expire = is_null($expire) ? $this->paid_to() : $expire;
return $format ? Config::date($expire) : $expire;
}
@ -128,6 +128,15 @@ class Model_Service extends ORM_OSB {
return $result;
}
/**
* Show the date we are invoiced to
*/
public function invoiced_to($format=FALSE) {
$x = $this->invoice_item->order_by('date_stop','DESC')->limit(1)->find();
return $format ? $x->display('date_stop') : $x->date_stop;
}
/**
* Display the service product name
*/
@ -136,7 +145,22 @@ class Model_Service extends ORM_OSB {
}
/**
* Returns TRUE of this service has a planend change
* Returns the date that an item has been paid to
*/
public function paid_to($format=FALSE) {
$x = NULL;
foreach ($this->invoice_item->order_by('date_stop','DESC')->order_by('date_orig','DESC')->find_all() as $iio)
if ($iio->invoice->due() == 0) {
$x = $iio;
break;
}
return $format ? ($x ? $x->display('date_stop') : '&nbsp;') : ($x ? $x->date_stop : NULL);
}
/**
* Returns TRUE of this service has a planned change
*/
public function pending_change() {
return $this->service_change()->loaded() ? TRUE : FALSE;
@ -219,18 +243,13 @@ class Model_Service extends ORM_OSB {
return $this->invoice_item->order_by('date_start,date_stop');
}
// @todo To implement
public function charges_new() {
return $this->charges();
}
/** LIST FUNCTIONS **/
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show invoice numbers.
// We only show service numbers.
if (! is_numeric($term))
return array();

View File

@ -21,6 +21,12 @@
<dd><?php echo HTML::anchor('product/view/'.$o->product_id,$o->product->title()); ?></dd>
<?php endif ?>
<dt>Invoiced To</dt>
<dd><?php echo $o->invoiced_to(TRUE); ?></dd>
<dt>Paid To</dt>
<dd><?php echo $o->paid_to(TRUE); ?></dd>
<dt>Date Next Invoice</dt>
<dd><?php echo $o->display('date_next_invoice'); ?></dd>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Task_SSL_Renew extends Task {
class Task_SSL_Renew extends Minion_Task {
/**
* Renew a certificate
*/