Page MenuHomePhabricator

[native] Store access token in Redux
ClosedPublic

Authored by tomek on Jan 29 2024, 5:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 6:49 PM
Unknown Object (File)
Sat, Nov 16, 6:49 PM
Unknown Object (File)
Sat, Nov 16, 6:49 PM
Unknown Object (File)
Sat, Nov 16, 6:48 PM
Unknown Object (File)
Oct 14 2024, 10:19 PM
Unknown Object (File)
Oct 14 2024, 10:19 PM
Unknown Object (File)
Oct 14 2024, 10:18 PM
Unknown Object (File)
Oct 14 2024, 10:18 PM
Subscribers

Details

Summary

Introduce a handler that:

  1. Reads the token from core module
  2. Listens for its changes
  3. Updates the store with the most recent value

https://linear.app/comm/issue/ENG-6597/store-csat-in-redux

Depends on D10866

Test Plan

Call commCoreModule.setCommServicesAuthMetadata and check if the token in Redux is updated. Add a timeout with a call to commCoreModule.setCommServicesAuthMetadata and check if it results in the token being updated.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek requested review of this revision.Jan 29 2024, 6:02 AM
This revision is now accepted and ready to land.Jan 29 2024, 7:35 AM
This revision was automatically updated to reflect the committed changes.
native/identity-service/identity-service-context-provider.react.js
18

Nit: not sure why this was separated into its own import. Probably not worth fixing at this point, but might be worth checking if your IDE is doing this accidentally

41

I think it's a little weird that we're still using the auth metadata emitter for the userID, but we're accessing the CSAT from Redux. Is there a reason for this inconsistency?

native/identity-service/identity-service-context-provider.react.js
18

I think we should fix this in whole codebase - created a task to configure ESLint rule https://linear.app/comm/issue/ENG-6607/add-no-duplicate-imports-rule-to-eslint-config

41

At this point, we have two different userIDs on a client:

  1. From a keyserver DB
  2. From identity service - UUID or a reserved ID

Ultimately, these should match, but currently, they're different. In the future, the emitter should update Redux and we could just select the ID here. Now we don't have a place in Redux to store this ID and I don't think it is worth it to introduce it.

native/identity-service/identity-service-context-provider.react.js
41

I would've assumed that it would be safe to use the userID from currentUserInfo, but I'm guessing that doesn't work for you because some reducer hasn't been updated yet, or maybe because your test plan isn't testing that part.

Can you create a follow-up task to update this logic to use the userID from currentUserInfo? It could potentially be a child of ENG-4567

native/identity-service/identity-service-context-provider.react.js
41

This will be partially addressed by ENG-6416 which will make currentUserInfo be set on identity login and register.
Then we will have to update this code here to use it.