GoodDollar / GoodServer

Backend to support the GoodDAPP
MIT License
13 stars 13 forks source link

(Bug) users database record not created #366

Closed sirpy closed 2 years ago

sirpy commented 2 years ago
johnsmith-gooddollar commented 2 years ago

@sirpy it's very strange case. according to the logs user deleted account then started FV. (without re-creation of account)

don't even imagine how this could happen. checking similar cases...

johnsmith-gooddollar commented 2 years ago

@sirpy Still couldn't understand what's happening with 0x477663a87e46b60981625430d00524ca2b600d61

But for the other similar cases i've found the users don't have crmId. The reason is addCRMRecord failed because of 3sec timeout.

I've opened PR with a temporary fix. It will re-check does we have crmId and create it if not after login (when we're calling for /userExists passing email and mobile) @vldkh will test it tomorrow on QA and we'll hotfix it to prod. Also this fix adds check for crmId during whitelisting to avoid the error in the logs.

But it won't work with reg methods providing email only. To fix the issue with passwordless mobile login we need different approach needs to be discussed. My suggestion is:

  1. /userExists should check for crmId in the case of existing and return it
  2. we're storing this flag somewhere (in AsyncStorage ?)
  3. after login we're checking storage.
  4. if crmid existense flag had been stored and strictly equals to false we're sending user's email and mobile from profile to some separate endpoint
  5. endpoint (e.g. /verify/crmId) checks if req.user have crm id, if not - calls createCRMRecord({ ...req.user, email, mobile }, req.cookies.__utmzz, req.log)

what do you think ?

sirpy commented 2 years ago

@johnsmith-gooddollar i've already have the code in updates that verifies users crmID, so we can just change the date on this update, to make it run again for everyone.