Add duplicate username check
This commit is contained in:
parent
6eadb5162a
commit
8a3893f33d
@ -33,6 +33,10 @@ def create_user(
|
||||
if not display_name.strip():
|
||||
display_name = username
|
||||
|
||||
# Query the db to make sure the username isn't taken
|
||||
if db.session.query(User.username == username).count() > 0:
|
||||
raise ArgumentError('Username is already taken')
|
||||
|
||||
new_user = User(
|
||||
username=username,
|
||||
password=password,
|
||||
|
@ -46,3 +46,6 @@ def test_create_user(db):
|
||||
assert new_user
|
||||
assert new_user.id is not None
|
||||
assert new_user.created is not None
|
||||
|
||||
with pytest.raises(ArgumentError):
|
||||
duplicate = userq.create_user(db, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user