From 420866ac0339b912a8eee330aab6db6222504eee Mon Sep 17 00:00:00 2001 From: b3yond Date: Fri, 16 Feb 2018 14:16:50 +0100 Subject: [PATCH] check if user already exists on registering --- frontend/website.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/website.py b/frontend/website.py index 4d8a39f..1f8a67a 100644 --- a/frontend/website.py +++ b/frontend/website.py @@ -43,7 +43,7 @@ def login(): uname = bottle.request.forms.get('uname') psw = bottle.request.forms.get('psw') psw = psw.encode("utf-8") - db.cur.execute("SELECT pass_hashed FROM user WHERE email=?;", (uname, )), psw + db.cur.execute("SELECT pass_hashed FROM user WHERE email=?;", (uname, )) try: pass_hashed = db.cur.fetchone()[0] except TypeError: @@ -69,6 +69,9 @@ def register(): return "ERROR: Passwords don't match. Try again." # check if email is already in use + db.cur.execute("SELECT id FROM user WHERE email=?;", (email,)) + if db.cur.fetchone() is not None: + return "E-Mail is already in use." # account already exists # hash and format for being encoded in the confirmation mail psw = psw.encode("utf-8")