helmgast / lore

A web-based storytelling framework.
4 stars 0 forks source link

Order attached to deleted user after merge? #318

Open ripperdoc opened 2 years ago

ripperdoc commented 2 years ago

Users [andreas.m] and [ak76] (emails anonymized)

The order ending with 8bd (DB) / 235 (Abicart) was associated with the deleted ak76 user, not the correct andreas.m user. The order was received 2022-02-07 11:34 but the user was merged on 2022-02-06 14:20

We may also have some issues with different timings below, should verify that the order/user-creation/log timestamps are matching and not off by some amount, as that can really mess up tracing.

Timeline:

2022-02-06 07:29:47.000Z, ORDER ...461 / ...425:  by ak76 created in Abicart
2022-02-06 10:02:25.612Z, ak76 join_date in DB
2022-02-06 14:18:15.573Z, andreas.m created at Auth0

[2022-02-06 14:20:54,205 INFO in auth:233] Linked email ak76@ to primary andreas.m@ (https://helmgast.se/auth/callback?link=andreas.m&next=https%3A%2F%2Fhelmgast.se%2Fsocial%2Fusers%2F61ffd8a93217350d34995283%3Fintent%3Dpatch&code=S_aYxkBOdOk_ICMV)

2022-02-06 17:37:56.000Z, ORDER 8bd / 235 user ak76 CREATED in Abicart
2022-02-07 11:34:03.752Z, ORDER 8bd / 235 user ak76 PAID in Abicart
[2022-02-07 11:34:03,865 INFO in admin:137] Imported <class 'lore.model.shop.Order'>('ObjectId('620103ab1db37d7f641cf8bd')', 'Webshop', '195041235', '<class 'lore.model.user.User'>('ObjectId('61ff9cb156a141a56ee43460')', 'ak76@', '2022-02-06 10:02:25.612000', 'deleted', 'None')', ''paid'') from 195041235, JOB-0: ''->SUCCESS

2022-02-08 00:50:22.108Z, andreas.m updated at Auth0
2022-02-08 00:50:22.941Z, andreas.m last login
2022-02-08 06:11:19.000Z, ORDER b85 / 981: andreas.m CREATED in Abicart

[2022-02-08 06:11:54,585 INFO in admin:137] Imported <class 'lore.model.shop.Order'>('ObjectId('620209aaa6e9eacba8c06b85')', 'Webshop', '195113981', '<class 'lore.model.user.User'>('ObjectId('61ffd8a93217350d34995283')', 'andreas.m@', '2022-02-06 10:02:25.612000', 'active', '[{'provider': 'google-oauth2', 'user_id': '109104865559908554478', 'connection': 'google-oauth2', 'isSocial': True}, {'profileData': {'email': 'ak76@', 'email_verified': True}, 'user_id': '61ffd90c70ad3d3140621c80', 'provider': 'email', 'connection': 'email', 'isSocial': False}]')', ''paid'') from 195113981, JOB-0: ''->SUCCESS
ripperdoc commented 1 year ago

Has seen this again in the logs, but now the merge happened several months before the new order came in, so there is no risk for timing issues.

ripperdoc commented 1 year ago

The error can be seen as we import a textalk order, the identified user is printed but has the status flag deleted. The method query_user_by_email should by default NOT return deleted users but something in the code is not working as expected.