nopCommerce icon indicating copy to clipboard operation
nopCommerce copied to clipboard

Require a customer to re-login on all devices after password changing

Open AndreiMaz opened this issue 3 years ago • 3 comments

Let's imagine that a customer is logged-in on multiple devices (e.g. laptop, a phone, etc). When a password is changed on one of devices, then we should we should require him (her) to re-logic on other devices.

Let's think about how we can implement it. Maybe, some kind of tokens

AndreiMaz avatar Aug 20 '20 10:08 AndreiMaz

Perhaps using the date in which the cookie is created and comparing it to the CreatedOnUtc date from the CustomerPassword table, and if it's older, then the device logs out and requires to re login.

Avron108 avatar Jan 17 '22 10:01 Avron108

There is no cookie creation date, only the expiration date, if I am not mistaken. You will need to create a custom cookie when the user logs in, but an additional check for each request may cause multiple calls to the database for each request. I tried it before for nopCommerce 4.00, but it caused a performance bottleneck due to many additional queries. I end up using server-sent events.

  • Each client subscribes to the SSE endpoint
  • When the password is changed, the customer GUID is broadcasted
  • If your browser's customer GUID matches the updated customer GUID, we set the cookie to force logout

This solution worked well and didn't add additional load to the server. There might be a need to add an extra encryption layer to hide the customer GUID if the disclosure of this GUID adds an additional security risk

ilich avatar Apr 03 '22 04:04 ilich

Hi, @ilich Your suggestion sounds interesting, could you share the implementation details via a pull request?

DmitriyKulagin avatar Apr 06 '22 08:04 DmitriyKulagin

Closed #4987

skoshelev avatar Dec 06 '22 14:12 skoshelev