Post by PetraLandgraf » Mon Dec 11, 2017 8:42 pm

Hi,
I ‘am Using OC 3.0.2. designing 3 stores, from which 2 are for common access and one is for registered dealers only.
The standard registration allows access to all stores.
I noticed that there is a store_id field in the OC_cutomer table. How can I use this field to add an extra check for login? (if not 2 than access denied)
Or has someone another suggestion to accomplice a unique login?

Newbie

Posts

Joined
Mon Dec 04, 2017 5:24 am

Post by straightlight » Mon Dec 11, 2017 9:14 pm

The standard registration allows access to all stores.
I noticed that there is a store_id field in the OC_cutomer table. How can I use this field to add an extra check for login? (if not 2 than access denied)
The standard registration of Opencart with default installation allows logins by stores for all customers ... not for all stores for all customers. As for the extra check, could you elaborate that a little?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by PetraLandgraf » Mon Dec 11, 2017 10:30 pm

Thanks for the swift aswer.
May be edit the store’s account login.twig (by using the theme/template editor).
add a line where there is a check if the store_id = 2
if yes then login success else the standard error message will doo fine

Newbie

Posts

Joined
Mon Dec 04, 2017 5:24 am

Post by straightlight » Mon Dec 11, 2017 10:40 pm

Strange that a store_id would be stored on the database but not re-gathered when a customer logs in ...

in catalog/model/account/customer.php file,

find:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
replace with:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by PetraLandgraf » Mon Dec 11, 2017 11:46 pm

thank you,
I did the modification, but sadly without result. I can still login using any customer account. Just to be sure, I cleared all cookies, restarted the server and tried different browsers, but that did not change anything. I hope you have some other tricks to solve my problem.

Best regards,
Petra

Newbie

Posts

Joined
Mon Dec 04, 2017 5:24 am

Post by straightlight » Mon Dec 11, 2017 11:55 pm

One more location is needed. In your system/library/cart/customer.php file,

find:

Code: Select all

$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "' AND status = '1'");
replace with:

Code: Select all

$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "' AND status = '1' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
Then, find:

Code: Select all

$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1'");
replace with:

Code: Select all

$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by PetraLandgraf » Tue Dec 12, 2017 1:12 am

Top!
This works perfect!
Thank You very much.

Petra Landgraf

Newbie

Posts

Joined
Mon Dec 04, 2017 5:24 am
Who is online

Users browsing this forum: Shiftcom, SohBH and 418 guests