Removed signup and added quotes
This commit is contained in:
parent
a1b4e5ea4d
commit
f14cdc0a78
@ -30,35 +30,35 @@ def login_post():
|
|||||||
return redirect(url_for('main.profile'))
|
return redirect(url_for('main.profile'))
|
||||||
|
|
||||||
|
|
||||||
@auth.route('/signup')
|
# @auth.route('/signup')
|
||||||
def signup():
|
# def signup():
|
||||||
return render_template('signup.html')
|
# return render_template('signup.html')
|
||||||
|
|
||||||
@auth.route('/signup', methods=['POST'])
|
# @auth.route('/signup', methods=['POST'])
|
||||||
def signup_post():
|
# def signup_post():
|
||||||
email = request.form.get('email')
|
# email = request.form.get('email')
|
||||||
name = request.form.get('name')
|
# name = request.form.get('name')
|
||||||
password = request.form.get('password')
|
# password = request.form.get('password')
|
||||||
google_id = request.form.get('google_id')
|
# google_id = request.form.get('google_id')
|
||||||
|
|
||||||
user = User.query.filter_by(email=email).first()
|
# user = User.query.filter_by(email=email).first()
|
||||||
|
|
||||||
if user:
|
# if user:
|
||||||
flash('Email already exists for user')
|
# flash('Email already exists for user')
|
||||||
return redirect(url_for('auth.signup'))
|
# return redirect(url_for('auth.signup'))
|
||||||
|
|
||||||
user = User.query.filter_by(google_id=google_id).first()
|
# user = User.query.filter_by(google_id=google_id).first()
|
||||||
|
|
||||||
if user:
|
# if user:
|
||||||
flash('Google ID already in use')
|
# flash('Google ID already in use')
|
||||||
return redirect(url_for('auth.signup'))
|
# return redirect(url_for('auth.signup'))
|
||||||
|
|
||||||
new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256'), google_id=google_id)
|
# new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256'), google_id=google_id)
|
||||||
|
|
||||||
db.session.add(new_user)
|
# db.session.add(new_user)
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
# Code to validate and add the user to the database
|
# # Code to validate and add the user to the database
|
||||||
return redirect(url_for('auth.login'))
|
# return redirect(url_for('auth.login'))
|
||||||
|
|
||||||
@auth.route('/logout')
|
@auth.route('/logout')
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
from .models import Quote
|
||||||
|
|
||||||
main = Blueprint('main', __name__)
|
main = Blueprint('main', __name__)
|
||||||
|
|
||||||
@ -18,3 +19,10 @@ def profile():
|
|||||||
google_id=current_user.google_id,
|
google_id=current_user.google_id,
|
||||||
is_admin=current_user.administrator
|
is_admin=current_user.administrator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@main.route('/quotes')
|
||||||
|
@login_required
|
||||||
|
def quotes():
|
||||||
|
quotes = [q.quote for q in Quote.query.all()]
|
||||||
|
return render_template("quotes.html", quotes=quotes)
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="is-clipped" xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
@ -24,14 +24,14 @@
|
|||||||
<a href="{{ url_for('main.profile') }}" class="navbar-item">
|
<a href="{{ url_for('main.profile') }}" class="navbar-item">
|
||||||
Profile
|
Profile
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ url_for('main.quotes') }}" class="navbar-item">
|
||||||
|
Quotes
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not current_user.is_authenticated %}
|
{% if not current_user.is_authenticated %}
|
||||||
<a href="{{ url_for('auth.login') }}" class="navbar-item">
|
<a href="{{ url_for('auth.login') }}" class="navbar-item">
|
||||||
Login
|
Login
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ url_for('auth.signup') }}" class="navbar-item">
|
|
||||||
Sign Up
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
<a href="{{ url_for('auth.logout') }}" class="navbar-item">
|
<a href="{{ url_for('auth.logout') }}" class="navbar-item">
|
||||||
@ -51,6 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user