Skip to content

Commit

Permalink
Added email validity checking feature to the account creation system
Browse files Browse the repository at this point in the history
  • Loading branch information
EndermanPC committed Feb 10, 2024
1 parent 9987f89 commit fbb043b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Binary file modified account/__pycache__/userid.cpython-312.pyc
Binary file not shown.
Binary file modified account/__pycache__/username.cpython-312.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions account/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import time
import streamlit as st
from account.loader import account_database_loader
Expand All @@ -24,6 +25,13 @@ def update_username(user_id, email, new_username):
sys_log("Changed Username", "Username: " + username + " User ID: " + str(user_id) + " Email: " + email + " Password: " + password)
conn.commit()

def verify_email(email):
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if(re.fullmatch(regex, email)):
return False
else:
return True

def check_existing_email(email):
cursor.execute("SELECT * FROM users WHERE email=?", (email,))
return cursor.fetchone() is not None
Expand Down Expand Up @@ -56,6 +64,8 @@ def check_existing_username(username):
if email and username and password:
if check_existing_email(email):
st.error('This email is already registered. Please use a different email.')
elif verify_email(email):
st.error('This email is invalid, please check again.')
elif check_existing_username(username):
st.error('This user name already in use. Please use another username.')
else:
Expand Down
Binary file modified database/users-account.db
Binary file not shown.

0 comments on commit fbb043b

Please sign in to comment.