You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existing codebase doesn't use database transactions for anything, so there are certain operations (such as creating a new user) that may fail, leaving the database in an invalid state.
check if a user exists with the same email - this is just a select query
insert the new user entry - this may fail if there has been a race condition and a new user has been created since the previous step took place
insert a hashed password into the database - if this step fails, we end up with a user entry that has no password, so it will be impossible to create a new user with the same email address
create a session cookie
add the session cookie to the response
We should just wrap the entire sequence of steps in a transaction, so that if something fails the pending changes to the database can be discarded.
The text was updated successfully, but these errors were encountered:
The existing codebase doesn't use database transactions for anything, so there are certain operations (such as creating a new user) that may fail, leaving the database in an invalid state.
For example, the "create user" function in https://github.com/canvasxyz/metropolis/blob/main/server/src/auth/create-user.ts#L13 consists of a number of steps that all need to take place successfully:
We should just wrap the entire sequence of steps in a transaction, so that if something fails the pending changes to the database can be discarded.
The text was updated successfully, but these errors were encountered: