parass13 commited on
Commit
0405c6e
Β·
verified Β·
1 Parent(s): 8093a58

Update dashboard.py

Browse files
Files changed (1) hide show
  1. 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
- conn = sqlite3.connect(db_path)
64
- cursor = conn.cursor()
65
- cursor.execute("SELECT * FROM user_details WHERE EMAIL = ?", (email,))
66
- if cursor.fetchone():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)