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 flask import render_template, redirect, request
from controllers.database.user import UserController from controllers.database.user import UserController
from models.users.customer import Customer from models.users.customer import Customer
from hashlib import sha512
# Function responsible for displaying the main landing page of the site # Function responsible for displaying the main landing page of the site
@ -34,7 +35,15 @@ def display_signup():
@blueprint.post('/signup') @blueprint.post('/signup')
def signup(): def signup():
database = UserController() 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("/") return redirect("/")

View File

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

View File

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