From 0da26c151a07b84d8b694060ee2f2e72dfeb59e7 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 30 Sep 2014 18:11:38 +0200 Subject: [PATCH] [TASK] Initial commit. --- .gitignore | 9 ++ app.py | 97 +++++++++++++++++++ requirements.txt | 1 + settings.example.py | 38 ++++++++ templates/admin.html | 4 + templates/base.html | 58 +++++++++++ templates/flask_user/_macros.html | 39 ++++++++ templates/flask_user/change_password.html | 17 ++++ templates/flask_user/change_username.html | 14 +++ templates/flask_user/emails/base_message.html | 7 ++ templates/flask_user/emails/base_message.txt | 7 ++ templates/flask_user/emails/base_subject.txt | 1 + .../emails/confirm_email_message.html | 15 +++ .../emails/confirm_email_message.txt | 13 +++ .../emails/confirm_email_subject.txt | 3 + .../emails/forgot_password_message.html | 13 +++ .../emails/forgot_password_message.txt | 11 +++ .../emails/forgot_password_subject.txt | 3 + .../emails/password_changed_message.html | 8 ++ .../emails/password_changed_message.txt | 12 +++ .../emails/password_changed_subject.txt | 3 + .../flask_user/emails/registered_message.html | 7 ++ .../flask_user/emails/registered_message.txt | 6 ++ .../flask_user/emails/registered_subject.txt | 3 + .../emails/username_changed_message.html | 6 ++ .../emails/username_changed_message.txt | 10 ++ .../emails/username_changed_subject.txt | 3 + templates/flask_user/forgot_password.html | 13 +++ templates/flask_user/login.html | 60 ++++++++++++ templates/flask_user/login_or_register.html | 61 ++++++++++++ templates/flask_user/manage_emails.html | 39 ++++++++ templates/flask_user/member_base.html | 2 + templates/flask_user/public_base.html | 2 + templates/flask_user/register.html | 46 +++++++++ .../flask_user/resend_confirm_email.html | 13 +++ templates/flask_user/reset_password.html | 16 +++ templates/index.html | 9 ++ templates/profile.html | 12 +++ 38 files changed, 681 insertions(+) create mode 100644 .gitignore create mode 100644 app.py create mode 100644 requirements.txt create mode 100644 settings.example.py create mode 100644 templates/admin.html create mode 100644 templates/base.html create mode 100644 templates/flask_user/_macros.html create mode 100644 templates/flask_user/change_password.html create mode 100644 templates/flask_user/change_username.html create mode 100644 templates/flask_user/emails/base_message.html create mode 100644 templates/flask_user/emails/base_message.txt create mode 100644 templates/flask_user/emails/base_subject.txt create mode 100644 templates/flask_user/emails/confirm_email_message.html create mode 100644 templates/flask_user/emails/confirm_email_message.txt create mode 100644 templates/flask_user/emails/confirm_email_subject.txt create mode 100644 templates/flask_user/emails/forgot_password_message.html create mode 100644 templates/flask_user/emails/forgot_password_message.txt create mode 100644 templates/flask_user/emails/forgot_password_subject.txt create mode 100644 templates/flask_user/emails/password_changed_message.html create mode 100644 templates/flask_user/emails/password_changed_message.txt create mode 100644 templates/flask_user/emails/password_changed_subject.txt create mode 100644 templates/flask_user/emails/registered_message.html create mode 100644 templates/flask_user/emails/registered_message.txt create mode 100644 templates/flask_user/emails/registered_subject.txt create mode 100644 templates/flask_user/emails/username_changed_message.html create mode 100644 templates/flask_user/emails/username_changed_message.txt create mode 100644 templates/flask_user/emails/username_changed_subject.txt create mode 100644 templates/flask_user/forgot_password.html create mode 100644 templates/flask_user/login.html create mode 100644 templates/flask_user/login_or_register.html create mode 100644 templates/flask_user/manage_emails.html create mode 100644 templates/flask_user/member_base.html create mode 100644 templates/flask_user/public_base.html create mode 100644 templates/flask_user/register.html create mode 100644 templates/flask_user/resend_confirm_email.html create mode 100644 templates/flask_user/reset_password.html create mode 100644 templates/index.html create mode 100644 templates/profile.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf19210 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +settings.py + +*.pyc +*~ +*.sqlite +.project +.settings +.buildpath +.pydevproject diff --git a/app.py b/app.py new file mode 100644 index 0000000..686d741 --- /dev/null +++ b/app.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- + +from flask import Flask, render_template_string, request +from flask.ext.babel import Babel +from flask.ext.mail import Mail +from flask.ext.sqlalchemy import SQLAlchemy +from flask.ext.user import current_user, login_required, SQLAlchemyAdapter, UserManager, UserMixin +from flask.ext.user import roles_required + +# Import config file containing secret information and more things. +from settings import ConfigClass, username_validator +from flask.templating import render_template + +def create_app(test_config=None): # For automated tests + # Setup Flask and read config from ConfigClass defined above + app = Flask(__name__) + app.config.from_object(__name__ + '.ConfigClass') + + # Load local_settings.py if file exists # For automated tests + try: app.config.from_object('local_settings') + except: pass + + # Load optional test_config # For automated tests + if test_config: + app.config.update(test_config) + + # Initialize Flask extensions + babel = Babel(app) # Initialize Flask-Babel + mail = Mail(app) # Initialize Flask-Mail + db = SQLAlchemy(app) # Initialize Flask-SQLAlchemy + + @babel.localeselector + def get_locale(): + translations = [str(translation) for translation in babel.list_translations()] + return request.accept_languages.best_match(translations) + + # Define the User-Roles pivot table + user_roles = db.Table('user_roles', + db.Column('id', db.Integer(), primary_key=True), + db.Column('user_id', db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')), + db.Column('role_id', db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))) + + # Define Role model + class Role(db.Model): + id = db.Column(db.Integer(), primary_key=True) + name = db.Column(db.String(50), unique=True) + + # Define User model. Make sure to add flask.ext.user UserMixin!! + class User(db.Model, UserMixin): + id = db.Column(db.Integer, primary_key=True) + active = db.Column(db.Boolean(), nullable=False, default=False) + username = db.Column(db.String(50), nullable=False, unique=True) + email = db.Column(db.String(255), nullable=False, unique=True) + confirmed_at = db.Column(db.DateTime()) + password = db.Column(db.String(255), nullable=False, default='') + reset_password_token = db.Column(db.String(100), nullable=False, default='') + # Relationships + roles = db.relationship('Role', secondary=user_roles, backref=db.backref('users', lazy='dynamic')) + + # Reset all the database tables + db.create_all() + + # Setup Flask-User + db_adapter = SQLAlchemyAdapter(db, User) + user_manager = UserManager(db_adapter, username_validator=username_validator) + user_manager.init_app(app) + + # Create the default admin user if not exists. + if not User.query.filter(User.username == ConfigClass.DDNS_ADMIN_USERNAME).first(): + adminuser = User(username=ConfigClass.DDNS_ADMIN_USERNAME, email=ConfigClass.DDNS_ADMIN_EMAIL, active=True, + password=user_manager.hash_password(ConfigClass.DDNS_ADMIN_PASSWORD)) + adminuser.roles.append(Role(name='admin')) + db.session.add(adminuser) + db.session.commit() + + @app.route('/') + def home_page(): + if current_user.is_authenticated(): + return profile_page() + return render_template('index.html') + + @app.route('/profile') + @login_required + def profile_page(): + return render_template('profile.html') + + @app.route('/special') + @roles_required('admin') + def special_page(): + return render_template('admin.html') + + return app + +""" Start development web server """ +if __name__ == '__main__': + app = create_app() + app.run(host='0.0.0.0', port=5000, debug=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..32b4f82 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask-user diff --git a/settings.example.py b/settings.example.py new file mode 100644 index 0000000..b8f06a2 --- /dev/null +++ b/settings.example.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from wtforms.validators import ValidationError + +class ConfigClass(object): + """ Configuration class """ + SECRET_KEY = 'THIS IS AN INSECURE SECRET' # Change this for production! + SQLALCHEMY_DATABASE_URI = 'sqlite:///minimal_app.sqlite' # Use Sqlite file db + CSRF_ENABLED = True + USER_ENABLE_EMAIL = True + USER_ENABLE_CHANGE_USERNAME = True + USER_ENABLE_CHANGE_PASSWORD = True + USER_ENABLE_FORGOT_PASSWORD = True + + USER_ENABLE_REGISTRATION = True # Turn to False to disable registration. + + """ Configure Flask-Mail """ + MAIL_SERVER = 'your.mailserver.here' + MAIL_PORT = 587 + MAIL_USE_SSL = True + MAIL_USE_TLS = True # Use this for STARTTLS! + MAIL_USERNAME = '' + MAIL_PASSWORD = '' + MAIL_DEFAULT_SENDER = '"Example Sender" ' + + """ Default Admin User """ + DDNS_ADMIN_USERNAME = 'admin' + DDNS_ADMIN_PASSWORD = 'SuperSecretAdminPassword' + DDNS_ADMIN_EMAIL = 'admin@service.example' + + +def username_validator(form, field): + """ Since usernames will be used for subdomains, take your time here. """ + username = field.data + if len(username) < 4: + raise ValidationError(_('Username must be at least 4 characters long')) + if not username.isalnum(): + raise ValidationError(_('Username may only contain letters and numbers')) diff --git a/templates/admin.html b/templates/admin.html new file mode 100644 index 0000000..c66a591 --- /dev/null +++ b/templates/admin.html @@ -0,0 +1,4 @@ +{% extends "base.html" %} +{% block content %} +

Admin area!

+{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..ea5bae6 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,58 @@ + + + + + + + Simple Dynamic DNS Service + + + + + + + + + + + + {% block body %} +
+
+
+

{% block title %}Simple Dynamic DNS Service{% endblock %}

+
+ {% block flash_messages %} + {%- with messages = get_flashed_messages(with_categories=true) -%} + {% if messages %} + {% for category, message in messages %} + {% if category=='error' %} + {% set category='danger' %} + {% endif %} +
{{ message|safe }}
+ {% endfor %} + {% endif %} + {%- endwith %} + {% endblock %} + + {% block content %} + {% endblock %} +
+ Have fun! +
+
+
+ {% endblock %} + + + + + + + \ No newline at end of file diff --git a/templates/flask_user/_macros.html b/templates/flask_user/_macros.html new file mode 100644 index 0000000..85c07e4 --- /dev/null +++ b/templates/flask_user/_macros.html @@ -0,0 +1,39 @@ +{% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%} +
+ {% if field.type != 'HiddenField' and label_visible %} + {% if not label %}{% set label=field.label.text %}{% endif %} + + {% endif %} + {{ field(class_='form-control', **kwargs) }} + {% if field.errors %} + {% for e in field.errors %} +

{{ e }}

+ {% endfor %} + {% endif %} +
+{%- endmacro %} + +{% macro render_checkbox_field(field, label=None) -%} + {% if not label %}{% set label=field.label.text %}{% endif %} +
+ +
+{%- endmacro %} + +{% macro render_radio_field(field) -%} + {% for value, label, _ in field.iter_choices() %} +
+ +
+ {% endfor %} +{%- endmacro %} + +{% macro render_submit_field(field, label=None, tabindex=None) -%} + {% if not label %}{% set label=field.label.text %}{% endif %} + {##} + +{%- endmacro %} diff --git a/templates/flask_user/change_password.html b/templates/flask_user/change_password.html new file mode 100644 index 0000000..d4480c4 --- /dev/null +++ b/templates/flask_user/change_password.html @@ -0,0 +1,17 @@ +{% extends 'flask_user/member_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Change Password{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.old_password, tabindex=10) }} + {{ render_field(form.new_password, tabindex=20) }} + {% if user_manager.enable_retype_password %} + {{ render_field(form.retype_password, tabindex=30) }} + {% endif %} + {{ render_submit_field(form.submit, tabindex=90) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/change_username.html b/templates/flask_user/change_username.html new file mode 100644 index 0000000..ab9aec2 --- /dev/null +++ b/templates/flask_user/change_username.html @@ -0,0 +1,14 @@ +{% extends 'flask_user/member_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Change Username{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.new_username, tabindex=10) }} + {{ render_field(form.old_password, tabindex=20) }} + {{ render_submit_field(form.submit, tabindex=90) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/base_message.html b/templates/flask_user/emails/base_message.html new file mode 100644 index 0000000..3551b7b --- /dev/null +++ b/templates/flask_user/emails/base_message.html @@ -0,0 +1,7 @@ +

Dear User,

+ +{% block message %} +{% endblock %} + +

Sincerely,
+The Flask-User Team

\ No newline at end of file diff --git a/templates/flask_user/emails/base_message.txt b/templates/flask_user/emails/base_message.txt new file mode 100644 index 0000000..c31de26 --- /dev/null +++ b/templates/flask_user/emails/base_message.txt @@ -0,0 +1,7 @@ +Dear User, + +{% block message %} +{% endblock %} + +Sincerely, +The Flask-User Team diff --git a/templates/flask_user/emails/base_subject.txt b/templates/flask_user/emails/base_subject.txt new file mode 100644 index 0000000..8c9ee64 --- /dev/null +++ b/templates/flask_user/emails/base_subject.txt @@ -0,0 +1 @@ +Flask-User: {% block subject %}{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/confirm_email_message.html b/templates/flask_user/emails/confirm_email_message.html new file mode 100644 index 0000000..5dbf591 --- /dev/null +++ b/templates/flask_user/emails/confirm_email_message.html @@ -0,0 +1,15 @@ +{% extends 'flask_user/emails/base_message.html' %} + +{% block message %} + +

Thank you for registering with Flask-User.

+ +{% if user_manager.enable_confirm_email %} +

Visit the link below to complete your registration:

+ +

Confirm your email address.

+ +

If you did not initiate this registration, you may safely ignore this email.

+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/confirm_email_message.txt b/templates/flask_user/emails/confirm_email_message.txt new file mode 100644 index 0000000..dd24b7f --- /dev/null +++ b/templates/flask_user/emails/confirm_email_message.txt @@ -0,0 +1,13 @@ +{% extends 'flask_user/emails/base_message.txt' %} + +{% block message %} +Thank you for registering with Flask-User. + +{% if user_manager.enable_confirm_email -%} +Visit the link below to complete your registration: +{{ confirm_email_link }} + +If you did not initiate this registration, you may safely ignore this email. + +{%- endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/confirm_email_subject.txt b/templates/flask_user/emails/confirm_email_subject.txt new file mode 100644 index 0000000..6154ba0 --- /dev/null +++ b/templates/flask_user/emails/confirm_email_subject.txt @@ -0,0 +1,3 @@ +{% extends 'flask_user/emails/base_subject.txt' %} + +{% block subject %}Registration Confirmation{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/forgot_password_message.html b/templates/flask_user/emails/forgot_password_message.html new file mode 100644 index 0000000..16d5e6d --- /dev/null +++ b/templates/flask_user/emails/forgot_password_message.html @@ -0,0 +1,13 @@ +{% extends 'flask_user/emails/base_message.html' %} + +{% block message %} + +

We have received your password reset request.

+ +

Visit the link below to provide a new password:

+ +

Reset your password.

+ +

If you did not initiate this password reset request, you may safely ignore this email.

+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/forgot_password_message.txt b/templates/flask_user/emails/forgot_password_message.txt new file mode 100644 index 0000000..2aacd79 --- /dev/null +++ b/templates/flask_user/emails/forgot_password_message.txt @@ -0,0 +1,11 @@ +{% extends 'flask_user/emails/base_message.txt' %} + +{% block message %} +We have received your password reset request. + +Visit the link below to provide a new password: +{{ reset_password_link }} + +If you did not initiate this password reset request, you may safely ignore this email. + +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/forgot_password_subject.txt b/templates/flask_user/emails/forgot_password_subject.txt new file mode 100644 index 0000000..655b402 --- /dev/null +++ b/templates/flask_user/emails/forgot_password_subject.txt @@ -0,0 +1,3 @@ +{% extends 'flask_user/emails/base_subject.txt' %} + +{% block subject %}Reset password{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/password_changed_message.html b/templates/flask_user/emails/password_changed_message.html new file mode 100644 index 0000000..7b4f9e0 --- /dev/null +++ b/templates/flask_user/emails/password_changed_message.html @@ -0,0 +1,8 @@ +{% extends 'flask_user/emails/base_message.html' %} + +{% block message %} +

Your password has been changed.

+{% if user_manager.enable_forgot_password %} +

If you did not change your password, click here to reset it.

+{% endif %} +{% endblock %} diff --git a/templates/flask_user/emails/password_changed_message.txt b/templates/flask_user/emails/password_changed_message.txt new file mode 100644 index 0000000..5c3f8c4 --- /dev/null +++ b/templates/flask_user/emails/password_changed_message.txt @@ -0,0 +1,12 @@ +{% extends 'flask_user/emails/base_message.txt' %} + +{% block message %} +Your password has been changed. + +{% if user_manager.enable_forgot_password -%} +If you did not change your password, click the link below to reset it. + {{ url_for('user.forgot_password', _external=True) }} +{% endif -%} +{% endblock %} + + diff --git a/templates/flask_user/emails/password_changed_subject.txt b/templates/flask_user/emails/password_changed_subject.txt new file mode 100644 index 0000000..1c3d89d --- /dev/null +++ b/templates/flask_user/emails/password_changed_subject.txt @@ -0,0 +1,3 @@ +{% extends 'flask_user/emails/base_subject.txt' %} + +{% block subject %}Your password has been changed{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/registered_message.html b/templates/flask_user/emails/registered_message.html new file mode 100644 index 0000000..4dece9e --- /dev/null +++ b/templates/flask_user/emails/registered_message.html @@ -0,0 +1,7 @@ +{% extends 'flask_user/emails/base_message.html' %} + +{% block message %} + +

Thank you for registering with Flask-User.

+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/registered_message.txt b/templates/flask_user/emails/registered_message.txt new file mode 100644 index 0000000..7347f3a --- /dev/null +++ b/templates/flask_user/emails/registered_message.txt @@ -0,0 +1,6 @@ +{% extends 'flask_user/emails/base_message.txt' %} + +{% block message %} +Thank you for registering with Flask-User. + +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/registered_subject.txt b/templates/flask_user/emails/registered_subject.txt new file mode 100644 index 0000000..6154ba0 --- /dev/null +++ b/templates/flask_user/emails/registered_subject.txt @@ -0,0 +1,3 @@ +{% extends 'flask_user/emails/base_subject.txt' %} + +{% block subject %}Registration Confirmation{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/emails/username_changed_message.html b/templates/flask_user/emails/username_changed_message.html new file mode 100644 index 0000000..e5a6f6b --- /dev/null +++ b/templates/flask_user/emails/username_changed_message.html @@ -0,0 +1,6 @@ +{% extends 'flask_user/emails/base_message.html' %} + +{% block message %} +

Your username has been changed.

+

If you did not change your username, please sign in (using your email address) and change your password.

+{% endblock %} diff --git a/templates/flask_user/emails/username_changed_message.txt b/templates/flask_user/emails/username_changed_message.txt new file mode 100644 index 0000000..2d6a1e6 --- /dev/null +++ b/templates/flask_user/emails/username_changed_message.txt @@ -0,0 +1,10 @@ +{% extends 'flask_user/emails/base_message.txt' %} + +{% block message %} +Your username has been changed. + +If you did not change your username, please sign in (using your email address) and change your password. + {{ url_for('user.login', _external=True) }} +{% endblock %} + + diff --git a/templates/flask_user/emails/username_changed_subject.txt b/templates/flask_user/emails/username_changed_subject.txt new file mode 100644 index 0000000..32a3602 --- /dev/null +++ b/templates/flask_user/emails/username_changed_subject.txt @@ -0,0 +1,3 @@ +{% extends 'flask_user/emails/base_subject.txt' %} + +{% block subject %}Your username has been changed{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/forgot_password.html b/templates/flask_user/forgot_password.html new file mode 100644 index 0000000..dedd47e --- /dev/null +++ b/templates/flask_user/forgot_password.html @@ -0,0 +1,13 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Forgot Password{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.email, tabindex=10) }} + {{ render_submit_field(form.submit, tabindex=90) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/login.html b/templates/flask_user/login.html new file mode 100644 index 0000000..ace3841 --- /dev/null +++ b/templates/flask_user/login.html @@ -0,0 +1,60 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Sign in{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + + {# Username or Email #} + {% set field = form.username if user_manager.enable_username else form.email %} +
+ {# Label on left, "New here? Register." on right #} +
+
+ +
+
+ {% if user_manager.enable_register and not user_manager.require_invitation %} + + {%trans%}New here? Register.{%endtrans%} + {% endif %} +
+
+ {{ field(class_='form-control', tabindex=110) }} + {% if field.errors %} + {% for e in field.errors %} +

{{ e }}

+ {% endfor %} + {% endif %} +
+ + {# Password #} + {% set field = form.password %} +
+ {# Label on left, "Forgot your Password?" on right #} +
+
+ +
+
+ {% if user_manager.enable_forgot_password %} + + {%trans%}Forgot your Password?{%endtrans%} + {% endif %} +
+
+ {{ field(class_='form-control', tabindex=120) }} + {% if field.errors %} + {% for e in field.errors %} +

{{ e }}

+ {% endfor %} + {% endif %} +
+ + {# Submit button #} + {{ render_submit_field(form.submit, tabindex=180) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/login_or_register.html b/templates/flask_user/login_or_register.html new file mode 100644 index 0000000..8808c98 --- /dev/null +++ b/templates/flask_user/login_or_register.html @@ -0,0 +1,61 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} + +
+
+ +

{%trans%}Sign in{%endtrans%}

+ +{# ** Login form ** #} +
+ {{ login_form.hidden_tag() }} + + {# Username or Email #} + {% set field = login_form.username if user_manager.enable_username else login_form.email %} + {{ render_field(field, tabindex=110) }} + + {# Password #} + {{ render_field(login_form.password, tabindex=120) }} + + {# Submit button #} + {{ render_submit_field(login_form.submit, tabindex=180) }} +
+ {% if user_manager.enable_forgot_password %} +

+
+ + {%trans%}Forgot your Password?{%endtrans%} +

+ {% endif %} + +
+
+ +

{%trans%}Register{%endtrans%}

+ +{# ** Register form ** #} +
+ {{ register_form.hidden_tag() }} + + {# Username or Email #} + {% set field = register_form.username if user_manager.enable_username else register_form.email %} + {{ render_field(field, tabindex=210) }} + + {% if user_manager.enable_email and user_manager.enable_username %} + {{ render_field(register_form.email, tabindex=220) }} + {% endif %} + + {{ render_field(register_form.password, tabindex=230) }} + + {% if user_manager.enable_retype_password %} + {{ render_field(register_form.retype_password, tabindex=240) }} + {% endif %} + + {{ render_submit_field(register_form.submit, tabindex=280) }} +
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/manage_emails.html b/templates/flask_user/manage_emails.html new file mode 100644 index 0000000..84b8fbf --- /dev/null +++ b/templates/flask_user/manage_emails.html @@ -0,0 +1,39 @@ +{% extends 'flask_user/member_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Manage Emails{%endtrans%}

+ + + +{% for user_email in user_emails %} + + + + + +{% endfor %} +
EmailStatusActions
{{ user_email.email }} + {% if user_email.confirmed_at %} + Confirmed + {% else %} + Confirm Email + {% endif %} + + {% if user_email.is_primary %} + Primary email + {% else %} + {% if user_email.confirmed_at %} + Make primary | + {% endif %} + Delete + {% endif %} +
+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.email) }} + {{ render_submit_field(form.submit) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/member_base.html b/templates/flask_user/member_base.html new file mode 100644 index 0000000..b65a6cb --- /dev/null +++ b/templates/flask_user/member_base.html @@ -0,0 +1,2 @@ +{% extends 'base.html' %} + diff --git a/templates/flask_user/public_base.html b/templates/flask_user/public_base.html new file mode 100644 index 0000000..b65a6cb --- /dev/null +++ b/templates/flask_user/public_base.html @@ -0,0 +1,2 @@ +{% extends 'base.html' %} + diff --git a/templates/flask_user/register.html b/templates/flask_user/register.html new file mode 100644 index 0000000..f952d02 --- /dev/null +++ b/templates/flask_user/register.html @@ -0,0 +1,46 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Register{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + + {# Username or Email #} + {% set field = form.username if user_manager.enable_username else form.email %} +
+ {# Label on left, "Already registered? Sign in." on right #} +
+
+ +
+
+ {% if user_manager.enable_register %} + + {%trans%}Already registered? Sign in.{%endtrans%} + {% endif %} +
+
+ {{ field(class_='form-control', tabindex=210) }} + {% if field.errors %} + {% for e in field.errors %} +

{{ e }}

+ {% endfor %} + {% endif %} +
+ + {% if user_manager.enable_email and user_manager.enable_username %} + {{ render_field(form.email, tabindex=220) }} + {% endif %} + + {{ render_field(form.password, tabindex=230) }} + + {% if user_manager.enable_retype_password %} + {{ render_field(form.retype_password, tabindex=240) }} + {% endif %} + + {{ render_submit_field(form.submit, tabindex=280) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/resend_confirm_email.html b/templates/flask_user/resend_confirm_email.html new file mode 100644 index 0000000..54f7360 --- /dev/null +++ b/templates/flask_user/resend_confirm_email.html @@ -0,0 +1,13 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Resend Confirmation Email{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.email, tabindex=10) }} + {{ render_submit_field(form.submit, tabindex=90) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/flask_user/reset_password.html b/templates/flask_user/reset_password.html new file mode 100644 index 0000000..58886ce --- /dev/null +++ b/templates/flask_user/reset_password.html @@ -0,0 +1,16 @@ +{% extends 'flask_user/public_base.html' %} + +{% block content %} +{% from "flask_user/_macros.html" import render_field, render_submit_field %} +

{%trans%}Reset Password{%endtrans%}

+ +
+ {{ form.hidden_tag() }} + {{ render_field(form.new_password, tabindex=10) }} + {% if user_manager.enable_retype_password %} + {{ render_field(form.retype_password, tabindex=20) }} + {% endif %} + {{ render_submit_field(form.submit, tabindex=90) }} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..2bb67ce --- /dev/null +++ b/templates/index.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block content %} +

{%trans%}Welcome!{%endtrans%}

+

+ {%trans%}Sign in{%endtrans%} or + {%trans%}Register{%endtrans%} +

+ +{% endblock %} \ No newline at end of file diff --git a/templates/profile.html b/templates/profile.html new file mode 100644 index 0000000..fc50d19 --- /dev/null +++ b/templates/profile.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block content %} +

{%trans%}Profile Page{%endtrans%}

+

+ {%trans%}Hello{%endtrans%} {{ current_user.username or current_user.email }}! +

+ +{% endblock %} \ No newline at end of file