To customize the login and registration pages in Flask-User, you can create your own templates that extend Flask-User's base templates and include your own branding and styles. Here's a step-by-step guide on how to do this:
Create a templates folder in your Flask application directory if you haven't done so already.
In the templates folder, create a new HTML file called login.html to customize the login page. This template should extend Flask-User's base.html and override the content block. Include your own branding, styles, and any additional content you'd like.
{% extends "flask_user/user_base.html" %}
{% block content %}
<div id="your_branding_container">
<!-- Add your branding, logo, or heading here -->
</div>
<div id="login_container">
<!-- Include the original Flask-User login form -->
{% include "flask_user/login_or_register_form.html" %}
</div>
<!-- Add your own styles or link to your stylesheets -->
<style>
/* Add custom styles for your branding and login form */
</style>
{% endblock %}
Similarly, create a new HTML file called register.html to customize the registration page:
{% extends "flask_user/user_base.html" %}
{% block content %}
<div id="your_branding_container">
<!-- Add your branding, logo, or heading here -->
</div>
<div id="register_container">
<!-- Include the original Flask-User registration form -->
{% include "flask_user/login_or_register_form.html" %}
</div>
<!-- Add your own styles or link to your stylesheets -->
<style>
/* Add custom styles for your branding and registration form */
</style>
{% endblock %}
Now, you need to tell Flask-User to use your custom templates for the login and registration views. In your Flask app configuration, add the following lines:
app.config['USER_LOGIN_TEMPLATE'] = 'login.html'
app.config['USER_REGISTER_TEMPLATE'] = 'register.html'
With these changes, Flask-User will use your custom login.html and register.html templates for the login and registration pages, respectively. You can now add your own branding, styles, and content to these pages by editing the templates.
If you want to customize other Flask-User templates, you can follow the same approach: create a new template that extends the base template, override the appropriate block, and update the corresponding configuration option. You can find the available template configuration options in the Flask-User documentation.