Tracking PR for registration rewrite #5
2 changed files with 48 additions and 2 deletions
|
@ -3,7 +3,7 @@ from flask import Blueprint, config, current_app, flash, redirect, render_templa
|
|||
import flask_login
|
||||
from flask_login import current_user
|
||||
from goathacks.registration.forms import LoginForm, RegisterForm
|
||||
from werkzeug.security import generate_password_hash
|
||||
from werkzeug.security import check_password_hash, generate_password_hash
|
||||
|
||||
from goathacks import db
|
||||
from goathacks.models import User
|
||||
|
@ -63,4 +63,21 @@ def register():
|
|||
|
||||
@bp.route("/login", methods=["GET", "POST"])
|
||||
def login():
|
||||
return "OK"
|
||||
form = LoginForm(request.form)
|
||||
|
||||
if request.method == 'POST':
|
||||
email = request.form.get('email')
|
||||
password = request.form.get('password')
|
||||
|
||||
user = User.query.filter_by(email=email).first()
|
||||
|
||||
if check_password_hash(user.password, password):
|
||||
flask_login.login_user(user)
|
||||
|
||||
flash("Welcome back!")
|
||||
|
||||
return redirect(url_for("dashboard.home"))
|
||||
else:
|
||||
flash("Incorrect password")
|
||||
|
||||
return render_template("login.html", form=form)
|
||||
|
|
29
goathacks/templates/login.html
Normal file
29
goathacks/templates/login.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div style="height: 100%;">
|
||||
<div id="registration-banner" class="parallax-container valign-wrapper">
|
||||
<div class="section">
|
||||
<h3 class="header-center text-darken-2">Login</h3>
|
||||
</div>
|
||||
<div class="parallax"><img src="{{url_for('static', filename='img/background1.jpg')}}"
|
||||
alt="background"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="section" style="background-color: #974355; padding: 20px;">
|
||||
<form method="post">
|
||||
{{ form.csrf_token }}
|
||||
<div>
|
||||
{{form.email}}<br/>{{ form.email.label}}
|
||||
</div>
|
||||
<div>
|
||||
{{form.password}}<br/>{{form.password.label}}
|
||||
</div>
|
||||
<div>
|
||||
{{form.submit}}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue