Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Capture the user's name at signup time
Browse files Browse the repository at this point in the history
Ref #18, #15
  • Loading branch information
marksparkza committed Jul 1, 2021
1 parent 33e8c10 commit 1b34969
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions odp/identity/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


class SignupForm(FlaskForm):
name = StringField(
label='Full name',
validators=[input_required()],
)
email = StringField(
label='Email address',
filters=[lambda s: s.lower() if s else s],
Expand Down
1 change: 1 addition & 0 deletions odp/identity/templates/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{% block content %}
<form action="{{ url_for('signup.signup', token=token) }}" method="POST">
{{ form.csrf_token }}
{{ render_field(form.name) }}
{{ render_field(form.email) }}
{{ render_field(form.password) }}
{{ render_field(form.confirm_password) }}
Expand Down
3 changes: 2 additions & 1 deletion odp/identity/views/signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def signup():
if form.validate():
email = form.email.data
password = form.password.data
name = form.name.data
try:
create_user_account(email, password)
create_user_account(email, password, name)

# the signup (and login) is completed via email verification
send_verification_email(email, challenge)
Expand Down
4 changes: 3 additions & 1 deletion odp/lib/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def validate_email_verification(email):
return user.id


def create_user_account(email, password=None):
def create_user_account(email, password=None, name=None):
"""
Create a new user account with the specified credentials.
Password may be omitted if the user is externally authenticated.
Expand All @@ -172,6 +172,7 @@ def create_user_account(email, password=None):
:param email: the input email address
:param password: (optional) the input plain-text password
:param name: (optional) the user's personal name
:return: the new user id
:raises ODPEmailInUse: if the email address is already associated with a user account
Expand All @@ -191,6 +192,7 @@ def create_user_account(email, password=None):
active=True,
verified=False,
superuser=False,
name=name,
)
user.save()

Expand Down

0 comments on commit 1b34969

Please sign in to comment.