Password Reset Validation, Removal of unnessary files, Service display updates
This commit is contained in:
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
?>
|
@@ -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);
|
||||
|
||||
// Run validation and save
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
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);
|
||||
// Store our new values
|
||||
$this->ao->values($this->request->post());
|
||||
|
||||
if (! $validation->check())
|
||||
SystemMessage::factory()
|
||||
->title(_('Record NOT updated'))
|
||||
->type('error')
|
||||
->body(_('Your updates didnt pass validation.').'<br/>'.$output);
|
||||
}
|
||||
->body(_('Your password didnt pass validation.'));
|
||||
|
||||
// Run validation and save
|
||||
elseif ($this->ao->changed())
|
||||
if ($this->ao->save()) {
|
||||
SystemMessage::factory()
|
||||
->title('Record updated')
|
||||
->type('success')
|
||||
->body(_('Your account record has been updated.'));
|
||||
|
||||
// Log the password reset
|
||||
$this->ao->log('Password reset');
|
||||
|
||||
HTTP::redirect('login');
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
});
|
||||
');
|
||||
|
||||
// @todo To add JS password validation (minimum length and both values equal)
|
||||
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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user