Removed the ability for duplicate accounts being able to be made

This commit is contained in:
Luke Else 2024-01-05 14:11:46 +00:00
parent c6ef411930
commit 08479c1134
2 changed files with 11 additions and 0 deletions

View File

@ -23,6 +23,10 @@ class DatabaseController(ABC):
setattr(obj, attr, value) setattr(obj, attr, value)
return obj return obj
"""
Set of CRUD methods to allow for Data manipulation on the backend
"""
@abstractmethod @abstractmethod
def create(self): def create(self):
pass pass

View File

@ -49,6 +49,12 @@ def display_signup(error: str = None):
@blueprint.post('/signup') @blueprint.post('/signup')
def signup(): def signup():
database = UserController() database = UserController()
# User already exists
if database.read(request.form['username']) != None:
error = "User, " + request.form['username'] + " already exists"
return display_signup(error)
database.create(Customer( database.create(Customer(
0, 0,
request.form['username'], request.form['username'],
@ -64,6 +70,7 @@ def signup():
return redirect("/login", code=307) return redirect("/login", code=307)
### SIGN OUT FUNCTIONALITY
# Function responsible for handling logouts from the site # Function responsible for handling logouts from the site
@blueprint.route('/logout') @blueprint.route('/logout')
def logout(): def logout():