-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create auth package and update template files
- Loading branch information
Showing
10 changed files
with
139 additions
and
75 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoding: utf-8 | ||
# create authentication blueprint here | ||
|
||
from flask import Blueprint | ||
auth = Blueprint('auth', __name__) | ||
from . import views |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# encoding: utf-8 | ||
# define routes for authenticated url | ||
|
||
from flask import render_template, redirect, url_for, flash | ||
from app.forms import loginForm | ||
from ..models import User | ||
from flask_login import login_required, login_user, logout_user | ||
from ..auth import auth | ||
|
||
@auth.route('/login') | ||
def sign_in(): | ||
form = loginForm() | ||
if form.validate_on_submit(): | ||
user = User.query.filter_by(email=form.email.data).first() | ||
if user and user.verify_pass(form.password.data): | ||
return redirect(url_for('auth.dashboard')) | ||
else: | ||
flash('Invalid credentials') | ||
return render_template('auth/login.html', form=form) | ||
return render_template('auth/login.html', form=form) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends 'base.html' %} | ||
{% import 'macro/wtf.html' as wtf %} | ||
{% block main %} | ||
<div class="signup-form"> | ||
<div class="container"> | ||
{{ wtf.loginForm(form) }} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters