login si signin done

This commit is contained in:
andrei-mihnea-cerbu
2024-01-13 03:18:17 +02:00
parent 7eb9cdd70d
commit a6a228ded9
26 changed files with 278 additions and 63 deletions
@@ -0,0 +1,2 @@
from .login import LoginModel
from .signup import SignupModel
@@ -0,0 +1,29 @@
import re
class LoginModel:
def __init__(self, password: str, email: str):
self.password = password
self.email = email
def validate(self):
errors = []
# Check if username, password, and email are provided
if not self.email:
errors.append("Email is required.")
email_pattern = re.compile(r"[^@]+@[^@]+\.[^@]+")
if not email_pattern.match(self.email):
errors.append("Invalid email format.")
if not self.password:
errors.append("Password is required.")
if len(self.password) < 8:
errors.append("Password must be at least 8 characters.")
if errors:
return False, errors
# If all validations pass, return True
return True, []
@@ -2,7 +2,7 @@ import re
class SignupModel:
def __init__(self, username:str, password:str, email:str):
def __init__(self, username: str, password: str, email: str):
self.username = username
self.password = password
self.email = email