Browse Source

Chapter 8: Authentication blueprint (8b)

master
T. Meissner 6 years ago
parent
commit
927b4119ea
5 changed files with 54 additions and 0 deletions
  1. +3
    -0
      app/__init__.py
  2. +7
    -0
      app/auth/__init__.py
  3. +7
    -0
      app/auth/views.py
  4. +9
    -0
      app/templates/auth/login.html
  5. +28
    -0
      migrations/versions/e7148b675688_.py

+ 3
- 0
app/__init__.py View File

@ -25,4 +25,7 @@ def create_app(config_name):
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
return app

+ 7
- 0
app/auth/__init__.py View File

@ -0,0 +1,7 @@
from flask import Blueprint
auth = Blueprint('auth', __name__)
from . import views

+ 7
- 0
app/auth/views.py View File

@ -0,0 +1,7 @@
from flask import render_template
from . import auth
@auth.route('/login')
def login():
return render_template('auth/login.html')

+ 9
- 0
app/templates/auth/login.html View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Flasky - Login{% endblock %}
{% block page_content %}
<div class="page-header">
<h1>Login</h1>
</div>
{% endblock %}

+ 28
- 0
migrations/versions/e7148b675688_.py View File

@ -0,0 +1,28 @@
"""empty message
Revision ID: e7148b675688
Revises:
Create Date: 2018-10-28 23:58:52.794660
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e7148b675688'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('password_hash', sa.String(length=128), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'password_hash')
# ### end Alembic commands ###

Loading…
Cancel
Save