user1636946
user1636946

Reputation: 145

Can you change how Opencart resets your passwod?

Whenever a customer forgets their password they go to a page where they just type in their email address and then and email is sent with a new password that's just a bunch of random characters. I've never seen any other shopping carts do this so this is very strange. Most carts send an email with a link where you click on it and then reset it. Has anyone seen like an extension that does this for Opencart? I am currently using Joomla 3.3.0 with Opencart 2.3.0. Thanks!

Upvotes: 0

Views: 1165

Answers (3)

user1636946
user1636946

Reputation: 145

Ok I have just been looking in the wrong places. I was looking for this solution for Opencart but actually I discovered that you can just use Joomla 3's default "Forgot Password" link on the user login page.

You can find this link at www.yoursite.com/index.php?option=com_users&lang=en&view=login and from there you'll see the "Forgot Your Password" link. When you do this it'll change the Joomla User's password and Opencart Customer's password. So I am just going to redirect Opencart's "Forgot Password" links to the Joomla one. Works perfect! Thanks for your help guys!

Upvotes: 0

Ramesh
Ramesh

Reputation: 1204

In opencart there is a default method to overwrite login by passing third parameter to /system/library/customer.php::login() for that you need email

So if you want to send password reset link just modify mail and send link, you need email as well and make sure you encrypt email id for security /catalog/controller/account/forgotten.php before $mail

$encemail = substr(sha1('?h,KqTn+D#}o'.$this->request->post['email']),0,20);
$url = $this->url->link('account/password','passkey='.$encemail,'SSL');

$subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
$message  = sprintf($this->language->get('text_greeting'), $this->config->get('config_name')) . "\n\n";
$message .= 'click on link to change password' . "\n\n";
$message .= $url;

Now when customer clicks on link it will redirect to change password page so we need to find the regarding email id by passkey on /catalog/controller/account/password.php

if (!$this->customer->isLogged()) {

    if(isset($this->request->get['passkey'])){
        $this->load->model('account/customer');
        $data = array(
            'key' => '?h,KqTn+D#}o',
            'passkey' => $this->request->get['passkey']
            );

        $email = $this->model_account_customer->getEmail($data);

        if ($email) {
            $this->customer->login($email['email'], '', true);
        }else{
            $this->session->data['redirect'] = $this->url->link('account/password', '', 'SSL');
            $this->redirect($this->url->link('account/login', '', 'SSL'));                  
        }

    }else{

        $this->session->data['redirect'] = $this->url->link('account/password', '', 'SSL');
        $this->redirect($this->url->link('account/login', '', 'SSL'));
    }
}

Now in above we have called a model function to find valid email by passkey so in /catalog/model/account/customer.php add a new function

public function getEmail($data){
$query = $this->db->query("SELECT email FROM " . DB_PREFIX . "customer WHERE SUBSTRING(sha1(CONCAT('" . $data['key'] . "',`email`)),1,20) = '" . $data['passkey'] ."' AND status = '1' AND approved = '1'");
return $query->row;
}

Good Luck

Upvotes: 4

user3509726
user3509726

Reputation: 67

Edit the user with the username "admin" and change the password field to 5f4dcc3b5aa765d61d8327deb882cf99. This string or hash changes the password to "password" (without the quotes)

you may reference

http://www.inmotionhosting.com/support/edu/opencart/339-how-to-reset-my-opencart-admin-password

Upvotes: -1

Related Questions