Hey there, i'm implemanting a creation of user pro...
# support-questions-legacy
d
Hey there, i'm implemanting a creation of user profil on my own database while a user is signin up. The user is created after the originalImplementation of my signup, and use some additional fields. My issue is, if there is an error in my database interaction, the user is still created in supertokens, and I can't do it before the supertokens signup because i need the user id. Is there a way to revert the user creation if is there any error ?
r
hey @DollarNavalex there is no full proof way to guarantee consistency here cause there is always a chance that if your db query fails, calling deleteUser in supertokens also fails.
So if you really want to be consistent, the best way would be to let the API throw a 500 error which would make the user see a something went wrong on the frontend -> they try to sign up -> that will fail with the email already exists -> they try to sign in -> and then you can check in the sign in API if the user exists in your db and if not, add it in there.
d
Hmm
Okay my other solution would be to first create the user in my own database, then create the supertokens user, then add the supertokens id to my user db, and delete it if there's an error
It should mitigate the flow
r
well, deleting the user in your db could also fail
d
Hmm
Well, in all scenario, it seems there could be an error in the process
That would stuck the subsequential signup
r
in which case, the user would try and sign in, and then you can update your db in sign in
(since signinup again woluld say the user already exists from supertokens)
d
In the case my user db already exist but not in supertokens ?
r
oh yea. So im talking about the solution that i described
d
The problem is, i take some additional fields in the signup, that populate my user db (for the moment just first and last names). If something goes wrong during signup, signin can't really fix it, or i allow those field to be empty and let the user fill it later
r
In your solution, you could detect that the user existed in your db, but not in supertokens, and then call supertokens sign up once again and continue with the flow
d
I guess I must implement this mitigation since an error can occur at both database level
8 Views