может кому пригодится, выкладываю
в общем сам родной шаблон twig восстановления пароля не менял а новый сделал и назвал swd_forgotten.twig
{{ header }}
<div id="account-forgotten" class="container">
<ul class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
{% endfor %}
</ul>
{% if error_warning %}
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}</div>
{% endif %}
<div class="row">{{ column_left }}
{% if column_left and column_right %}
{% set class = 'col-md-6 col-sm-8 col-xs-12' %}
{% elseif column_left or column_right %}
{% set class = 'col-md-9 col-sm-8 col-xs-12' %}
{% else %}
{% set class = 'col-sm-12' %}
{% endif %}
<div id="content" class="{{ class }}">{{ content_top }}
<div class="inspire-form-bg">
<h1 class="heading">{{ cheading_title }}</h1>
<p>{{ text_email }}</p>
<div class="row infos"></div>
<form id="swd-forgotten" method="post" enctype="multipart/form-data" class="form-horizontal">
<fieldset>
<legend>{{ text_your_email }}</legend>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-email">{{ entry_email }}</label>
<div class="col-sm-10">
<input type="email" name="email" value="{{ email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control" />
</div>
</div>
</fieldset>
<div class="buttons clearfix">
<div class="pull-left"><a href="{{ back }}" class="btn btn-default">{{ button_back }}</a></div>
<div class="pull-right">
<input type="submit" value="{{ button_continue }}" class="btn btn-primary" />
</div>
</div>
</form>
<script type="text/javascript" >
var swdloader = '{{ load }}';
$(document).ready(function() {
$('#swd-forgotten').on('submit', function() {
var formData = $('#swd-forgotten').serialize();
var dataStr = formData+'&action=swdforgotten';
$.ajax({
type: 'POST',
url: 'index.php?route=account/forgotten/swd_forgot',
dataType: 'json',
data: dataStr,
cache: false,
beforeSend: function(){
$('.infos').html('<img src="' + swdloader + '">').show();
},
success: function(json){
if(json.success) {
$('.form-control').val('');
$('.infos').html(json.response.mes);
setTimeout('location.replace("' + json.response.link + '")', 1900);
} else {
setTimeout($('.infos').html(json.response), 700);
}
}
});
return false;
});
});
</script>
</div>
{{ content_bottom }}</div>
{{ column_right }}</div>
</div>
{{ footer }}
я по ходу еще использую свой хелпер он в папке helper/default.php
вот его код
function swd_json_success( $json ) {
$response = array( 'success' => true );
if ( isset( $json ) ) {
$response['response'] = $json;
}
echo json_encode( $response );
exit();
}
function swd_json_error( $json ) {
$response = array( 'success' => false );
if ( isset( $json ) ) {
$response['response'] = $json;
}
echo json_encode( $response );
exit();
}
function swd_info( $info, $def = true ) {
$html = '';
$css = 'success';
if( !$def )
$css = 'danger';
$html .= '<div class="alert swd-alert swd-'.$css.'">';
$html .= '<i class="fa fa-check-circle"></i> '.$info;
$html .= '<button type="button" class="close" data-dismiss="alert">×</button>';
$html .= '</div>';
return $html;
}
function clearText( $data ) {
$data = trim($data);
$data = stripslashes($data);
$data = preg_replace("/ +/", " ", $data);
$data = str_replace('#39;', '', $data);
$data = str_replace("`", '"', $data);
$data = str_replace("'", '"', $data);
$data = preg_replace('/"([^"]*)"/', '«$1»', $data);
$data = preg_replace('#<script[^>]*>.*?</script>#is', '', $data);
$data = str_replace('/^(.+?)(\?.*?)?(#.*)?$/', '$1$3', $data);
$data = strip_tags($data);
return $data;
}
////////////////////////////////////////////////////////
//////// Validate swd form cotact //////////////
////////////////////////////////////////////////////////
function check_email( $email ) {
if (function_exists('filter_var'))
return filter_var($email, FILTER_VALIDATE_EMAIL);
else
return preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+\.)+[a-z]{2,6}$/i", $email);
}
теперь сами правки в controller/account/forgotten.php
метод public function index() { в самый конец
//////////////////////////////////////////////////////////////
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
$data['load'] = $server . 'image/swdmail/load8.gif';
//////////////////////////////////////////////////////////////
//$this->response->setOutput($this->load->view('account/forgotten', $data));
$this->response->setOutput($this->load->view('account/swd_forgotten', $data));
кстати еще в папке image создал папку и туда лоадер загрузил. кому надо gif лоадер в сети скачает.
идем дальше
после protected function validate() { вставляем
///////////////////////////////////
$this->error['info'] = true;
////////////////////////////////////
вот так должно быть
protected function validate() {
///////////////////////////////////
$this->error['info'] = true;
////////////////////////////////////
if (!isset($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_email');
} elseif (!$this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_email');
}
// Check if customer has been approved.
$customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
if ($customer_info && !$customer_info['status']) {
$this->error['warning'] = $this->language->get('error_approved');
}
return !$this->error;
}
это чтоб старый вариант обработки не работал
ну и сами методы
//////////////////////////////////////////////////////////
/////// Validate form forgotten ajax
//////////////////////////////////////////////////////////
public function swd_forgot() {
//гружу свой хелпер
$this->load->helper('default');
$this->load->model('account/customer');
$this->load->language('account/forgotten');
if( $this->request->post['action'] == 'swdforgotten' ) {
if( ($this->request->server['REQUEST_METHOD'] == 'POST') && $this->swd_validate() ) {
$this->model_account_customer->editCode($this->request->post['email'], token(40));
$redirect = $this->url->link('account/account', '', true);
$json = array('mes' => swd_info( sprintf($this->language->get('forgotten_success'), $this->request->post['email']) ), 'link' => $redirect);
swd_json_success( $json );
}
//если есть ошибки выводим
if( isset($this->error['info']) ) {
$info = $this->error['info'];
} else {
$info = '';
}
swd_json_error( swd_info( $info, false ) );
} else {
swd_json_error( swd_info( $this->language->get('error_send'), false ) );
}
}
protected function swd_validate() {
if (!isset($this->request->post['email'])) {
$this->error['info'] = $this->language->get('error_email');
} elseif (!$this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['info'] = $this->language->get('error_email');
}
if( !check_email($this->request->post['email']) ) {
$this->error['info'] = $this->language->get('error_mail_valid');
}
if( empty($this->request->post['email']) ) {
$this->error['info'] = $this->language->get('error_mail_empty');
}
// Check if customer has been approved.
$customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
if ($customer_info && !$customer_info['status']) {
$this->error['info'] = $this->language->get('error_approved');
}
return !$this->error;
}
еще в языковой файл forgotten.php добавил вот эти строки
$_['error_mail_valid'] = 'Введите правильный Email!';
$_['error_mail_empty'] = 'Введите адрес электронной почты';
$_['error_send'] = 'Ошибка запроса! Обратитесь к администрации.';
$_['forgotten_success'] = 'На %s адрес электронной почты было отправлено письмо со ссылкой для подтверждения.';
ну в общем все