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'))
|
||||
|
||||
|
||||
@auth.route('/signup')
|
||||
def signup():
|
||||
return render_template('signup.html')
|
||||
# @auth.route('/signup')
|
||||
# def signup():
|
||||
# return render_template('signup.html')
|
||||
|
||||
@auth.route('/signup', methods=['POST'])
|
||||
def signup_post():
|
||||
email = request.form.get('email')
|
||||
name = request.form.get('name')
|
||||
password = request.form.get('password')
|
||||
google_id = request.form.get('google_id')
|
||||
# @auth.route('/signup', methods=['POST'])
|
||||
# def signup_post():
|
||||
# email = request.form.get('email')
|
||||
# name = request.form.get('name')
|
||||
# password = request.form.get('password')
|
||||
# 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:
|
||||
flash('Email already exists for user')
|
||||
return redirect(url_for('auth.signup'))
|
||||
# if user:
|
||||
# flash('Email already exists for user')
|
||||
# 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:
|
||||
flash('Google ID already in use')
|
||||
return redirect(url_for('auth.signup'))
|
||||
# if user:
|
||||
# flash('Google ID already in use')
|
||||
# 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.commit()
|
||||
# Code to validate and add the user to the database
|
||||
return redirect(url_for('auth.login'))
|
||||
# db.session.add(new_user)
|
||||
# db.session.commit()
|
||||
# # Code to validate and add the user to the database
|
||||
# return redirect(url_for('auth.login'))
|
||||
|
||||
@auth.route('/logout')
|
||||
@login_required
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required, current_user
|
||||
from .models import Quote
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
@ -18,3 +19,10 @@ def profile():
|
||||
google_id=current_user.google_id,
|
||||
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>
|
||||
<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>
|
||||
<meta charset="utf-8">
|
||||
@ -24,14 +24,14 @@
|
||||
<a href="{{ url_for('main.profile') }}" class="navbar-item">
|
||||
Profile
|
||||
</a>
|
||||
<a href="{{ url_for('main.quotes') }}" class="navbar-item">
|
||||
Quotes
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if not current_user.is_authenticated %}
|
||||
<a href="{{ url_for('auth.login') }}" class="navbar-item">
|
||||
Login
|
||||
</a>
|
||||
<a href="{{ url_for('auth.signup') }}" class="navbar-item">
|
||||
Sign Up
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if current_user.is_authenticated %}
|
||||
<a href="{{ url_for('auth.logout') }}" class="navbar-item">
|
||||
@ -51,6 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user