Page MenuHomePhabricator

[identity] Store device code version and login date
ClosedPublic

Authored by bartek on Dec 19 2023, 4:52 AM.
Tags
None
Referenced Files
F2147509: D10398.id.diff
Sun, Jun 30, 2:16 AM
Unknown Object (File)
Sat, Jun 29, 11:48 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Mon, Jun 24, 9:51 PM
Subscribers

Details

Summary

For primary device "migration", we need to store device code version along with the timestam at which access token was generated. This is required for ENG-5841.

Depends on D10397

Test Plan

Registered a new user and verified that the device code version and login date are stored in the database.
Logged in as that user but with a new device, made sure the data is stored for the new device too.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Dec 19 2023, 6:30 AM
bartek added inline comments.
services/identity/src/client_service.rs
223 ↗(On Diff #34828)

This is the timestamp access token is "minted". Since it is generated in all Login/Register RPCs right after this call (AccessTokenData::new()), I let myself use Utc::now() for simplicity

791 ↗(On Diff #34828)

Reusing existing get_version_info() actually resulted in more code than implementing this func

varun requested changes to this revision.Jan 10 2024, 1:45 PM
varun added inline comments.
services/identity/src/client_service.rs
223 ↗(On Diff #34828)

wouldn't it be more correct to create the access token and then call add_password_user_to_users_table with that token's created field?

This revision now requires changes to proceed.Jan 10 2024, 1:45 PM
bartek added inline comments.
services/identity/src/client_service.rs
223 ↗(On Diff #34828)

The problem is that AccessTokenData::new() (see L229 below) already requires user_id so this call needs to be first 😕

This "login time" is a temporary thing anyway so I see two ways out:

  1. Leave this as-is
  2. [maybe more correct] Call let login_time = Utc::now() above both calls and provide login_time to both add_password_user_to_users_table() and AccessTokenData::new()
varun requested changes to this revision.Jan 11 2024, 9:28 AM

back to you

services/identity/src/client_service.rs
223 ↗(On Diff #34828)

ah I see. i think we should do option 2, but rather than changing AccessTokenData::new(), we should add a new method AccessTokenData::with_created_time()

This revision now requires changes to proceed.Jan 11 2024, 9:28 AM

Implemented option 2 as suggested

This revision is now accepted and ready to land.Jan 11 2024, 10:33 AM