Signup page now populates database correctly

This commit is contained in:
Luke Else 2024-01-01 23:13:09 +00:00
parent efdd918a9f
commit b26bd1a228
3 changed files with 29 additions and 16 deletions

View File

@ -2,6 +2,7 @@ from . import blueprint
from flask import render_template, redirect, request
from controllers.database.user import UserController
from models.users.customer import Customer
from hashlib import sha512
# Function responsible for displaying the main landing page of the site
@ -34,7 +35,15 @@ def display_signup():
@blueprint.post('/signup')
def signup():
database = UserController()
database.create(Customer())
database.create(Customer(
0,
request.form['username'],
request.form['email'],
request.form['firstname'],
request.form['lastname'],
"123",
sha512(request.form['password'].encode()).hexdigest(), # Hashed as soon as it is recieved on the backend
"Customer"
))
print("Tryin to signup as " + request.form['username'])
return redirect("/")

View File

@ -6,8 +6,11 @@ class Customer(User):
No additional properties are assigned to the customer
'''
def __init__(self):
super().__init__()
def __init__(self, id: int, username: str, email: str, firstname: str,
lastname: str, phone: str, password: str, role: str):
super().__init__(
id, username, email, firstname, lastname, phone, password, role
)
def login(self):
print("Logging in as Customer")

View File

@ -1,18 +1,19 @@
from abc import ABC, abstractmethod
class User(ABC):
'''
Class constructor to instatiate the base object
'''
def __init__(self):
self.id = 0
self.username = ""
self.email = ""
self.firstName = ""
self.lastName = ""
self.phone = ""
self.password = ""
self.role=""
""" Functional Class constructor to initialise all properties in the base object
with a value """
def __init__(self, id: int, username: str, email: str, firstname: str,
lastname: str, phone: str, password: str, role: str):
self.id = id
self.username = username
self.email = email
self.firstName = firstname
self.lastName = lastname
self.phone = phone
self.password = password
self.role= role
@abstractmethod
def login(self):