Skip to content

Commit

Permalink
Added: placeholder create user and login ui routes (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Mar 29, 2024
1 parent 3908a7c commit 9d2b3a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
35 changes: 26 additions & 9 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,11 +1731,33 @@ async def ui_privacy(request: Request):
}
)

@app.get("/ui/auth/login", response_class=HTMLResponse)
async def ui_auth_login(request: Request):
if not config.UI_ENABLED:
raise HTTPException(status_code=404, detail="This page does not exist")

return templates.TemplateResponse(
request=request,
name="login.html.jinja",
context={
**build_ui_context(),
}
)

# Create user
# @app.get("/ui/auth/create")
# async def ui_auth_create():
# if not config.UI_ENABLED:
# raise HTTPException(status_code=404, detail="This page does not exist")
@app.get("/ui/auth/create", response_class=HTMLResponse)
async def ui_auth_create(request: Request):
if not config.UI_ENABLED:
raise HTTPException(status_code=404, detail="This page does not exist")

return templates.TemplateResponse(
request=request,
name="create_user.html.jinja",
context={
**build_ui_context(),
}
)




Expand All @@ -1753,11 +1775,6 @@ async def ui_privacy(request: Request):
# raise HTTPException(status_code=404, detail="This page does not exist")


# Login
# @app.get("/ui/auth/login")
# async def ui_auth_login():
# if not config.UI_ENABLED:
# raise HTTPException(status_code=404, detail="This page does not exist")


# View profile
Expand Down
4 changes: 2 additions & 2 deletions libreforms_fastapi/app/templates/create_user.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Create User

{% block content %}
<h1>Create User</h1>
<form id="registrationForm" method="POST" action="{{ url_for('create_user') }}">
<form id="registrationForm" method="POST" action="">

<fieldset style="padding-top: 10px;" class="form-check">
<label aria-labelledby="usernameHelpInline" for="username" class="form-check-label">Username</label>
Expand Down Expand Up @@ -79,7 +79,7 @@ Create User
</fieldset>

<fieldset style="padding-top: 10px;" class="form-check">
<p style="padding-top: 10px;">Already have an account? Login <a href="{{url_for('login')}}">here</a>.</p>
<p style="padding-top: 10px;">Already have an account? Login <a href="{{url_for('ui_auth_login')}}">here</a>.</p>
</fieldset>

</form>
Expand Down
4 changes: 2 additions & 2 deletions libreforms_fastapi/app/templates/login.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Login

{% block content %}
<h1>Login</h1>
<form method="POST" action="{{ url_for('login') }}">
<form method="POST" action="">


<fieldset style="padding-top: 10px;" class="form-check">
Expand Down Expand Up @@ -34,7 +34,7 @@ Login

{% if not config['DISABLE_NEW_USERS'] %}
<fieldset style="padding-top: 10px;" class="form-check">
<p style="padding-top: 10px;">Don't have an account? Create one <a href="{{url_for('create_user')}}">here</a>.</p>
<p style="padding-top: 10px;">Don't have an account? Create one <a href="{{url_for('ui_auth_create')}}">here</a>.</p>
</fieldset>
{% endif %}

Expand Down

0 comments on commit 9d2b3a3

Please sign in to comment.