Spaces:
Running
Running
Update dashboard.py
Browse files- dashboard.py +27 -14
dashboard.py
CHANGED
@@ -53,28 +53,41 @@ def predict_image(image):
|
|
53 |
prediction = deepfake_model.predict(preprocessed)[0][0]
|
54 |
return "β
Real Image" if prediction >= 0.5 else "β οΈ Fake Image"
|
55 |
|
56 |
-
# Auth logic (now using local DB connection inside each function)
|
57 |
def register_user(name, phone, email, password):
|
|
|
|
|
58 |
if not is_valid_email(email):
|
|
|
59 |
return "β Invalid email"
|
60 |
if not is_valid_phone(phone):
|
|
|
61 |
return "β Phone must be 10 digits"
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
conn.close()
|
68 |
-
return "β οΈ Email already registered"
|
69 |
|
70 |
-
hashed_pw = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
|
71 |
-
cursor.execute(
|
72 |
-
"INSERT INTO user_details (NAME, PHONE, EMAIL, GENDER, PASSWORD) VALUES (?, ?, ?, ?, ?)",
|
73 |
-
(name, phone, email, "U", hashed_pw)
|
74 |
-
)
|
75 |
-
conn.commit()
|
76 |
-
conn.close()
|
77 |
-
return "β
Registration successful! Please log in."
|
78 |
|
79 |
def login_user(email, password):
|
80 |
conn = sqlite3.connect(db_path)
|
|
|
53 |
prediction = deepfake_model.predict(preprocessed)[0][0]
|
54 |
return "β
Real Image" if prediction >= 0.5 else "β οΈ Fake Image"
|
55 |
|
|
|
56 |
def register_user(name, phone, email, password):
|
57 |
+
print(f"Attempting to register: {name}, {phone}, {email}") # β
Add this line
|
58 |
+
|
59 |
if not is_valid_email(email):
|
60 |
+
print("Invalid email")
|
61 |
return "β Invalid email"
|
62 |
if not is_valid_phone(phone):
|
63 |
+
print("Invalid phone")
|
64 |
return "β Phone must be 10 digits"
|
65 |
|
66 |
+
try:
|
67 |
+
conn = sqlite3.connect(db_path)
|
68 |
+
cursor = conn.cursor()
|
69 |
+
|
70 |
+
cursor.execute("SELECT * FROM user_details WHERE EMAIL = ?", (email,))
|
71 |
+
if cursor.fetchone():
|
72 |
+
print("Duplicate email")
|
73 |
+
return "β οΈ Email already registered"
|
74 |
+
|
75 |
+
hashed_pw = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
|
76 |
+
cursor.execute(
|
77 |
+
"INSERT INTO user_details (NAME, PHONE, EMAIL, GENDER, PASSWORD) VALUES (?, ?, ?, ?, ?)",
|
78 |
+
(name, phone, email, "U", hashed_pw)
|
79 |
+
)
|
80 |
+
conn.commit()
|
81 |
+
print("β
Registration successful")
|
82 |
+
return "β
Registration successful! Please log in."
|
83 |
+
|
84 |
+
except sqlite3.Error as e:
|
85 |
+
print("β SQLite error:", e)
|
86 |
+
return f"β DB Error: {str(e)}"
|
87 |
+
|
88 |
+
finally:
|
89 |
conn.close()
|
|
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
def login_user(email, password):
|
93 |
conn = sqlite3.connect(db_path)
|