-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support refreshing tokens #87
Conversation
a430721
to
51f9855
Compare
42d05d9
to
4968ed2
Compare
|
||
func (s *Storage) UpdateUserIDForDevice(deviceID, userID string) error { | ||
_, err := s.db.Exec(`UPDATE syncv3_sync2_devices SET user_id = $1 WHERE device_id = $2`, userID, deviceID) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now need to know the user_id in order to form a device_id; prior to this it was possible that the user id had not yet been fetched from /whoami.
Come to think of it, we could make the user_id column non null here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, it already is null. It's just that sometimes we put the empty string into this column.
There are six entries in this table with user_id = ''
. But they all have since = ''
too. I think we ought to drop such devices from the table.
|
||
// Either: create a brand-new row for this device, or | ||
// update an existing row for this device with the latest access token. | ||
// TODO: If the latter, we need to tell any existing poller about the new token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Highlighting this TODO
func (h *Handler) ensureDeviceIDMigrated(d sync2.Device) error { | ||
if internal.IsNewDeviceID(d.DeviceID) { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to write some kind of test for this. E.g.
- manually insert old-style rows into all relevant tables,
- run the migration
- check it succeeds and that we can select the migrated data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks exactly as I'd expect.
|
||
func (s *Storage) UpdateUserIDForDevice(deviceID, userID string) error { | ||
_, err := s.db.Exec(`UPDATE syncv3_sync2_devices SET user_id = $1 WHERE device_id = $2`, userID, deviceID) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
Closing in favour of newer PRs, #90 for starters. |
Closes #51.
VERY WIP
I am going to force push to this, review at your own peril