-
Notifications
You must be signed in to change notification settings - Fork 2
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: Do not automatically assign demoUser
s the teamEditor
role within the Templates team
#3878
Conversation
demoUser
s the teamEditor
role within the Templates team
fc95e79
to
7994d30
Compare
|
||
CREATE CONSTRAINT TRIGGER grant_new_user_template_team_access | ||
AFTER INSERT ON users | ||
DEFERRABLE INITIALLY DEFERRED |
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.
DEFERRABLE INITIALLY DEFERRED
is new to me!
This ensures that the the trigger will run post commit, not post insert.
The insert of a new user and the associated demoUser
role are grouped into a single transaction via the GraphQL mutation here.
Without DEFERRABLE INITIALLY DEFERRED
, the trigger will run after the user has been inserted and then hit a race condition against insertion of the team_member
record (it may check for the record before it's been inserted).
This will now wait until both the users
record and team_members
record has been inserted before running.
const response = await safely(() => | ||
$admin.client.request<{ insertUsersOne: { id: number } }>( | ||
gql` | ||
mutation CreateAndAddUserToTeam( |
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 matches the query on the frontend - might be a good reason to wrap up on planx-core
?
7994d30
to
b63b6e3
Compare
Removed vultr server and associated DNS entries |
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.
Working as intended for me. The DEFERRABLE INITIALLY DEFERRED
bit was interesting, nice new bit of SQL
What does this PR do?
demoUser
role, they are not automatically granted theteamEditor
role in the "templates" team✅ Regression tests passing against this branch here