Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions zeeguu/api/endpoints/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def add_user(email):
"""

password = request.form.get("password")
username = request.form.get("username")
name = request.form.get("name")
learned_language_code = request.form.get(
"learned_language", "de"
) # default language; it's changed by the ui later
Expand All @@ -59,7 +59,7 @@ def add_user(email):
try:
new_user = create_account(
db_session,
username,
name,
password,
invite_code,
email,
Expand Down Expand Up @@ -105,13 +105,13 @@ def add_basic_user(email):
from ...core.account_management.user_account_creation import create_basic_account

password = request.form.get("password")
username = request.form.get("username")
name = request.form.get("name")
invite_code = request.form.get("invite_code")
platform = request.form.get("platform")

try:
new_user = create_basic_account(
db_session, username, password, invite_code, email, creation_platform=platform
db_session, name, password, invite_code, email, creation_platform=platform
)
new_session = Session.create_for_user(new_user)
db_session.add(new_session)
Expand Down
12 changes: 6 additions & 6 deletions zeeguu/api/test/test_account_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@


def test_add_user(client):
test_user_data = dict(password=TEST_PASS, username=TEST_USER)
test_user_data = dict(password=TEST_PASS, name=TEST_USER)

response = client.post(f"/add_user/{TEST_EMAIL}", data=test_user_data)
assert str(response.data)


def test_cant_add_same_email_twice(client):
test_user_data = dict(password=TEST_PASS, username=TEST_USER)
test_user_data = dict(password=TEST_PASS, name=TEST_USER)
response = client.post(f"/add_user/{TEST_EMAIL}", data=test_user_data)
assert str(response.data)

Expand All @@ -28,19 +28,19 @@ def test_cant_add_same_email_twice(client):


def test_create_user_returns_400_if_password_too_short(client):
form_data = dict(username="gigi", password="2sh", invite_code="test")
form_data = dict(name="gigi", password="2sh", invite_code="test")
response = client.post("/add_user/i@i.la", data=form_data)
assert response.status_code == 400


def test_create_user_returns_400_if_password_absent(client):
form_data = dict(username="gigi", invite_code="test")
form_data = dict(name="gigi", invite_code="test")
response = client.post("/add_user/i@i.la", data=form_data)
assert response.status_code == 400


def test_create_user_returns_400_if_password_not_given(client):
form_data = dict(username="gigi")
form_data = dict(name="gigi")
response = client.post("/add_user/i@i.la", data=form_data)
assert response.status_code == 400

Expand Down Expand Up @@ -103,6 +103,6 @@ def test_reset_password_returns_400_invalid_code(client):


def _create_test_user(client):
test_user_data = dict(password=TEST_PASS, username=TEST_USER)
test_user_data = dict(password=TEST_PASS, name=TEST_USER)

_ = client.post(f"/add_user/{TEST_EMAIL}", data=test_user_data)
12 changes: 6 additions & 6 deletions zeeguu/core/account_management/user_account_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def valid_invite_code(invite_code):
# TODO: delete after the new onboarding of Iga is done
def create_account(
db_session,
username,
name,
password,
invite_code,
email,
Expand Down Expand Up @@ -62,7 +62,7 @@ def create_account(

new_user = User(
email,
username,
name,
password,
invitation_code=invite_code,
learned_language=learned_language,
Expand Down Expand Up @@ -93,7 +93,7 @@ def create_account(

db_session.commit()

send_new_user_account_email(username, invite_code, cohort_name)
send_new_user_account_email(name, invite_code, cohort_name)

# Send email verification code
code = UniqueCode(email)
Expand All @@ -111,7 +111,7 @@ def create_account(
raise Exception("Could not create the account")


def create_basic_account(db_session, username, password, invite_code, email, creation_platform=None):
def create_basic_account(db_session, name, password, invite_code, email, creation_platform=None):
cohort_name = ""
if password is None or len(password) < 4:
raise Exception("Password should be at least 4 characters long")
Expand All @@ -130,7 +130,7 @@ def create_basic_account(db_session, username, password, invite_code, email, cre

try:
new_user = User(
email, username, password, invitation_code=invite_code, creation_platform=creation_platform
email, name, password, invitation_code=invite_code, creation_platform=creation_platform
)
new_user.email_verified = False # Require email verification

Expand All @@ -143,7 +143,7 @@ def create_basic_account(db_session, username, password, invite_code, email, cre

db_session.commit()

send_new_user_account_email(username, invite_code, cohort_name)
send_new_user_account_email(name, invite_code, cohort_name)

# Send email verification code
code = UniqueCode(email)
Expand Down
Loading