feat: password confirmation

This commit is contained in:
cellarspoon 2022-01-10 10:17:35 +01:00
parent e50ffa50ee
commit de207e3153
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
4 changed files with 32 additions and 8 deletions

View File

@ -44,7 +44,7 @@ async def register_invite(
"invalid.html", context=context
)
context = {"request": request, "username": username}
context = {"request": request, "invited_by": username}
return request.app.state.templates.TemplateResponse(
"register.html", context=context
)
@ -58,9 +58,24 @@ def form_keycloak_register(
username: str = Form(...),
email: str = Form(...),
password: str = Form(...),
password_again: str = Form(...),
invited_by: str = Form(...),
):
if password != password_again:
context = {
"request": request,
"exception": "passwords don't match?",
"invited_by": invited_by,
"first_name": first_name,
"last_name": last_name,
"username": username,
"email": email,
}
return request.app.state.templates.TemplateResponse(
"register.html", context=context
)
payload = {
"email": email,
"username": username,
@ -76,7 +91,7 @@ def form_keycloak_register(
"realmRoles": [
"user_default",
],
"attributes": {"invited_by": username},
"attributes": {"invited_by": invited_by},
}
try:

View File

@ -1,5 +1,6 @@
input {
display: block;
margin-top: 5px;
margin-bottom: 15px;
}

View File

@ -1,5 +1,6 @@
input {
display: block;
margin-top: 5px;
margin-bottom: 15px;
}

View File

@ -1,26 +1,33 @@
{% extends "base.html" %}
{% block content %}
<p>
You've been invited by {{ username }} 🎉
You've been invited by {{ invited_by }} 🎉
</p>
{% if exception %}
<p>Oops, something went wrong: {{ exception }} 😬</p>
{% endif %}
<form method="post" action="{{ url_for('form_keycloak_register') }}">
<label for="first_name">First name:</label>
<input type="text" name="first_name" />
<input type="text" name="first_name" value="{{ first_name }}" />
<label for="last_name">Last name:</label>
<input type="text" name="last_name" />
<input type="text" name="last_name" value="{{ last_name }}" />
<label for="username">Username:</label>
<input type="text" name="username" />
<input type="text" name="username" value="{{ username }}" />
<label for="email">Email:</label>
<input type="text" name="email" />
<input type="text" name="email" value="{{ email }}" />
<label for="password">Password:</label>
<input type="password" name="password" />
<input type="hidden" name="invited_by" value="{{ username }}"/>
<label for="password_again">Password (just to be sure):</label>
<input type="password" name="password_again" />
<input type="hidden" name="invited_by" value="{{ invited_by }}"/>
<input type="submit" value="Register" />
</form>