Applied auto pep 8 changes

This commit is contained in:
2024-01-21 22:06:06 +00:00
parent f227727c74
commit 44c1ee03ba
22 changed files with 156 additions and 100 deletions

View File

@@ -10,13 +10,17 @@ from hashlib import sha512
# Blueprint to append user endpoints to
blueprint = Blueprint("users", __name__)
### LOGIN FUNCTIONALITY
# LOGIN FUNCTIONALITY
# Function responsible for delivering the Login page for the site
@blueprint.route('/login')
def display_login():
return render_template('index.html', content="login.html")
# Function responsible for handling logins to the site
@blueprint.post('/login')
def login():
database = UserController()
@@ -28,7 +32,7 @@ def login():
error = "No user found with the username " + request.form['username']
flash(error)
return redirect("/login")
# Incorrect Password
if sha512(request.form['password'].encode()).hexdigest() != user.password:
error = "Incorrect Password"
@@ -39,13 +43,15 @@ def login():
return redirect("/")
### SIGNUP FUNCTIONALITY
# SIGNUP FUNCTIONALITY
# Function responsible for delivering the Signup page for the site
@blueprint.route('/signup')
def display_signup():
return render_template('index.html', content="signup.html")
# Function responsible for handling signups to the site
@blueprint.post('/signup')
def signup():
database = UserController()
@@ -60,7 +66,8 @@ def signup():
if request.form.get('seller'):
user = Seller(
request.form['username'],
sha512(request.form['password'].encode()).hexdigest(), # Hashed as soon as it is recieved on the backend
# Hashed as soon as it is recieved on the backend
sha512(request.form['password'].encode()).hexdigest(),
request.form['firstname'],
request.form['lastname'],
request.form['email'],
@@ -69,23 +76,24 @@ def signup():
else:
user = Customer(
request.form['username'],
sha512(request.form['password'].encode()).hexdigest(), # Hashed as soon as it is recieved on the backend
# Hashed as soon as it is recieved on the backend
sha512(request.form['password'].encode()).hexdigest(),
request.form['firstname'],
request.form['lastname'],
request.form['email'],
"123"
)
database.create(user)
# Code 307 Preserves the original request (POST)
return redirect("/login", code=307)
### SIGN OUT FUNCTIONALITY
# SIGN OUT FUNCTIONALITY
# Function responsible for handling logouts from the site
@blueprint.route('/logout')
def logout():
# Clear the current user from the session if they are logged in
session.pop('user_id', None)
return redirect("/")
return redirect("/")