Automatic Scraping of dataset options #9
@@ -1,6 +1,10 @@
|
||||
import re
|
||||
|
||||
from server.db.database import PostgresConnector
|
||||
from flask_bcrypt import Bcrypt
|
||||
|
||||
EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+")
|
||||
|
||||
class AuthManager:
|
||||
def __init__(self, db: PostgresConnector, bcrypt: Bcrypt):
|
||||
self.db = db
|
||||
@@ -18,6 +22,12 @@ class AuthManager:
|
||||
def register_user(self, username, email, password):
|
||||
hashed_password = self.bcrypt.generate_password_hash(password).decode("utf-8")
|
||||
|
||||
if len(username) < 3:
|
||||
raise ValueError("Username must be longer than 3 characters")
|
||||
|
||||
if not EMAIL_REGEX.match(email):
|
||||
raise ValueError("Please enter a valid email address")
|
||||
|
||||
if self.get_user_by_email(email):
|
||||
raise ValueError("Email already registered")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user