Overhauled the way in which user details are passed to the frontend

This commit is contained in:
2024-01-19 11:57:53 +00:00
parent 19165220fa
commit b2e32d720c
5 changed files with 55 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ from flask import Blueprint
from flask import render_template, redirect, request, session, flash
from controllers.database.user import UserController
from models.users.user import User
from models.users.customer import Customer
from models.users.seller import Seller
from hashlib import sha512
@@ -13,7 +14,7 @@ blueprint = Blueprint("users", __name__)
# Function responsible for delivering the Login page for the site
@blueprint.route('/login')
def display_login():
return render_template('index.html', content="login.html", user = session.get('user'))
return render_template('index.html', content="login.html")
# Function responsible for handling logins to the site
@blueprint.post('/login')
@@ -34,7 +35,7 @@ def login():
flash(error)
return redirect("/login")
session['user'] = user.username
session['user_id'] = user.id
return redirect("/")
@@ -42,7 +43,7 @@ def login():
# Function responsible for delivering the Signup page for the site
@blueprint.route('/signup')
def display_signup():
return render_template('index.html', content="signup.html", user = session.get('user'))
return render_template('index.html', content="signup.html")
# Function responsible for handling signups to the site
@blueprint.post('/signup')
@@ -55,7 +56,7 @@ def signup():
flash(error)
return redirect("/signup")
# Signup as seller or Customer
# Signup as Seller or Customer
if request.form.get('seller'):
user = Seller(
request.form['username'],
@@ -85,5 +86,5 @@ def signup():
# Function responsible for handling logouts from the site
@blueprint.route('/logout')
def logout():
session.pop('user')
session.pop('user_id')
return redirect("/")