ashrithagowthami commited on
Commit
4b692b3
·
verified ·
1 Parent(s): 795daf2

Upload server.py

Browse files
Files changed (1) hide show
  1. server.py +9 -5
server.py CHANGED
@@ -33,12 +33,16 @@ def init_db():
33
  is_active boolean, face_data text, last_login datetime,
34
  password text
35
  )''')
36
- # FORCE INIT: Ensure the password is set correctly for this account on every start
37
- c.execute("UPDATE users SET password = 'CBIT2024' WHERE LOWER(email) = 'ugs23020_csm.gowthami@cbit.org.in'")
38
- if c.rowcount == 0:
39
- print("DEBUG: Student email not found in DB during auto-init!")
 
 
 
40
  else:
41
- print("DEBUG: Password auto-initialized to CBIT2024")
 
42
 
43
  conn.commit()
44
  c.execute('''CREATE TABLE IF NOT EXISTS sessions (
 
33
  is_active boolean, face_data text, last_login datetime,
34
  password text
35
  )''')
36
+ # FORCE INIT: Ensure the student exists and has the correct password on every start
37
+ email = 'ugs23020_csm.gowthami@cbit.org.in'
38
+ c.execute("SELECT id FROM users WHERE LOWER(email) = ?", (email,))
39
+ if not c.fetchone():
40
+ c.execute("INSERT INTO users (id, email, name, role, roll_number, is_active, password) VALUES (?, ?, ?, ?, ?, ?, ?)",
41
+ (str(uuid.uuid4()), email, 'Gowthami', 'student', 'UGS23020', True, 'CBIT2024'))
42
+ print(f"DEBUG: Created new student account for {email}")
43
  else:
44
+ c.execute("UPDATE users SET password = 'CBIT2024' WHERE LOWER(email) = ?", (email,))
45
+ print(f"DEBUG: Updated password for existing account {email}")
46
 
47
  conn.commit()
48
  c.execute('''CREATE TABLE IF NOT EXISTS sessions (