-
Notifications
You must be signed in to change notification settings - Fork 25
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
Feat!: Auth user db sync #2666
Feat!: Auth user db sync #2666
Conversation
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.
Looks good, I'm not concerned about the breaking change - don't think any deployment is using this yet.
I'll leave testing to @jfmcquade
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.
I've been having an issue with my local postgres installation after making some local changes to where I install packages. I haven't been able to run the api locally and test, and need to finish for the day.
The code and description look good so I'm happy for this to be merged to unblock the continuing work.
PR Checklist
Breaking Changes
The contact field
_app_auth_user
has been renamed toauth_user_id
and is no longer formatted as json but instead just an id. I'm not sure if this protected field was included in any templates beyond debug ones. It has been updated in example_google_authThe current
app_user_id
remains unchangedDescription
Adds an
auth_users
endpoint to the server that can be used to retrieve a user by a givenauth_user_id
. It also creates an explicitauth_user_id
column within theapp_users
table to make it more efficient to retrieve (instead of looking at contact_fields)Updates server sync code to include
auth_user_id
when availableThese server updates are required to then enable lookup and restore of a given user by their auth_id (instead of device id)
Follow-ups
Author Notes
The updates here are mostly at the server level and will not work until the server is updated post-merge.
I had thought about exposing action triggers to better-enable authors to update templates based on auth events (e.g.
auth_signed_in
andauth_signed_out
), however this started to get a little bit complicated so for now I've manually updated it so whenever a user signs in theserver_sync
action is immediately triggered to ensure the signed in user profile is backed up to the db. If wanting to have more fine-grained support at an authoring level can create a follow-up issue.Review Notes
If testing endpoints locally will need locally running postgres and API
A local deployment will also need to be set to target the locally running endpoint
Alternatively can build API and run in docker container following instructions from the
api
andserver
package readmesOnce running performing a user sync from the
debug_sync_id
template or/user
debug page.You should see the user populated without an
auth_user_id
Sign_in either from the example_google_auth template and trigger sync and should see db populated with
auth_user_id
propertyExamples in screenshots below
Dev Notes
The
app_auth_user
property has been removed in favour ofauth_user_id
which is namespaced better and also stores a simple string representation instead of JSON.There is a small amount of placeholder code for the start of the user profile restore frontend feature, although for now this is still a work-in-progress and can be ignored for review
Git Issues
Closes #
Screenshots/Videos
Example sync non-auth user to API running locally
Note that the response now includes an auth_user_id (null)
Example sync post-login - includes
auth_user_id
response from server