diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/__init__.py | 9 | ||||
-rw-r--r-- | app/forms/app_forms.py | 4 | ||||
-rw-r--r-- | app/templates/auth/signin.html | 28 |
3 files changed, 40 insertions, 1 deletions
diff --git a/app/__init__.py b/app/__init__.py index 7145f96..1c759e7 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -3,12 +3,16 @@ from flask import Flask from flask_bcrypt import Bcrypt from flask.cli import AppGroup from flask_sqlalchemy import SQLAlchemy +import flask_login app = Flask(__name__) app.config.from_object('app.config') bcrypt = Bcrypt(app) db = SQLAlchemy(app) +login_manager = flask_login.LoginManager() + +login_manager.init_app(app) from app.models import User @@ -22,5 +26,8 @@ def delete_database(): app.cli.add_command(database_cli) +from app.views import main -from app.views import main
\ No newline at end of file +@login_manager.user_loader +def load_user(email): + return User.query.filter(User.email == email).first()
\ No newline at end of file diff --git a/app/forms/app_forms.py b/app/forms/app_forms.py index 2e2991d..005b53a 100644 --- a/app/forms/app_forms.py +++ b/app/forms/app_forms.py @@ -14,3 +14,7 @@ class UserSignUp(FlaskForm): last_name = StringField('Last Name') email = EmailField('Email',validators=[DataRequired(),Email()]) password = PasswordField('Password',validators=[DataRequired()]) + +class UserLogIn(FlaskForm): + email = EmailField('Email',validators=[DataRequired()]) + password = PasswordField('Password',validators=[DataRequired()])
\ No newline at end of file diff --git a/app/templates/auth/signin.html b/app/templates/auth/signin.html new file mode 100644 index 0000000..eecff34 --- /dev/null +++ b/app/templates/auth/signin.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} + +{% block title %}Sign Up{% endblock %} + +{% block head %} + {{ super() }} +{% endblock %} + +{% block content %} + <div class="container"> + <h1 class="display-2">User Login</h1> + <p>Sign in to your account.</p> + <form method="POST"> + {% include 'flash_messages.html' %} + {{ form.csrf_token }} + {% from "_formhelpers.html" import render_field %} + <div class="form-group"> + {{ render_field(form.email) }} + </div> + <div class="form-group"> + {{ render_field(form.password) }} + </div> + <div class="form-group"> + <input class="btn btn-primary" type="submit" value="Submit"> + </div> + </form> +</div> +{% endblock %}
\ No newline at end of file |