Rollback transaction if user creation fails
This commit is contained in:
parent
0c378ba07c
commit
cb45db291e
@ -37,6 +37,7 @@ class Users(object):
|
|||||||
db.session.add(user)
|
db.session.add(user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
|
db.session.rollback()
|
||||||
raise AlreadyExistsError("user")
|
raise AlreadyExistsError("user")
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
Loading…
x
Reference in New Issue
Block a user