Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/11458
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed May 31, 2023
1 parent 2617f69 commit 513a222
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
41 changes: 23 additions & 18 deletions upload/catalog/controller/account/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@
namespace Opencart\Catalog\Controller\Account;
class Login extends \Opencart\System\Engine\Controller {
public function index(): void {
if ($this->customer->isLogged() && ) {
if (!isset($this->session->data['redirect'])) {
$redirect = $this->url->link('account/account', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']);
} else {
$redirect = $this->session->data['redirect'];

unset($this->session->data['redirect']);
}

$this->response->redirect($redirect);
}

// If already logged in and has matching token then redirect to account page
if ($this->customer->isLogged() && isset($this->request->get['customer_token']) && isset($this->session->data['customer_token']) && ($this->request->get['customer_token'] == $this->session->data['customer_token'])) {


$this->response->redirect($this->url->link('account/account', 'user_token=' . $this->session->data['user_token']));


$this->response->redirect($this->url->link('account/account', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']));
}

$this->load->language('account/login');
Expand All @@ -43,7 +28,27 @@ public function index(): void {
'href' => $this->url->link('account/login', 'language=' . $this->config->get('config_language'))
];

if (isset($this->session->data['error'])) {
// Check to see if user is using incorrect token
if (isset($this->session->data['customer_token'])) {
$data['error_warning'] = $this->language->get('error_token');

$this->customer->logout();

unset($this->session->data['customer']);
unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
unset($this->session->data['customer_token']);
} elseif (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];

unset($this->session->data['error']);
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/language/en-gb/account/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$_['entry_password'] = 'Password';

// Error
$_['error_token'] = 'Warning: Login token invalid!';
$_['error_token'] = 'Warning: Invalid token session. Please login again!';
$_['error_login'] = 'Warning: No match for E-Mail Address and/or Password.';
$_['error_attempts'] = 'Warning: Your account has exceeded allowed number of login attempts. Please try again in 1 hour.';
$_['error_approved'] = 'Warning: Your account requires approval before you can login.';

0 comments on commit 513a222

Please sign in to comment.