DSatishchandra commited on
Commit
0eb739b
·
verified ·
1 Parent(s): b12f5e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -15,13 +15,14 @@ print("Salesforce connection established.")
15
  # Set the secret key to handle sessions securely
16
  app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
17
 
18
- # Session configuration
 
19
  app.config["SESSION_TYPE"] = "filesystem"
20
  app.config["SESSION_COOKIE_NAME"] = "biryanihub_session"
21
- app.config["SESSION_PERMANENT"] = False
22
- app.config["SESSION_USE_SIGNER"] = True
23
- app.config["SESSION_COOKIE_SECURE"] = False # Change to True if using HTTPS
24
  app.config["SESSION_COOKIE_HTTPONLY"] = True
 
25
 
26
  # Ensure secure session handling for environments like Hugging Face
27
  app.session_interface = SecureCookieSessionInterface()
@@ -55,6 +56,7 @@ def login():
55
  if request.method == "POST":
56
  email = request.form.get("email")
57
  password = request.form.get("password")
 
58
  print(f"Login attempt with email: {email}") # Debug log
59
 
60
  try:
@@ -65,6 +67,7 @@ def login():
65
  session['user_id'] = result["records"][0]['Id']
66
  session['user_email'] = email
67
  print(f"Session variables set: user_id={session['user_id']}, user_email={session['user_email']}")
 
68
  return redirect(url_for("menu"))
69
  else:
70
  print("Invalid credentials!")
 
15
  # Set the secret key to handle sessions securely
16
  app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
17
 
18
+ # Session Configuration
19
+ app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q")
20
  app.config["SESSION_TYPE"] = "filesystem"
21
  app.config["SESSION_COOKIE_NAME"] = "biryanihub_session"
22
+ app.config["SESSION_COOKIE_PATH"] = "/"
23
+ app.config["SESSION_COOKIE_SECURE"] = False
 
24
  app.config["SESSION_COOKIE_HTTPONLY"] = True
25
+ app.config["SESSION_PERMANENT"] = False
26
 
27
  # Ensure secure session handling for environments like Hugging Face
28
  app.session_interface = SecureCookieSessionInterface()
 
56
  if request.method == "POST":
57
  email = request.form.get("email")
58
  password = request.form.get("password")
59
+ print(f"Login Succesful")
60
  print(f"Login attempt with email: {email}") # Debug log
61
 
62
  try:
 
67
  session['user_id'] = result["records"][0]['Id']
68
  session['user_email'] = email
69
  print(f"Session variables set: user_id={session['user_id']}, user_email={session['user_email']}")
70
+ print(f"Session cookie: {app.session_interface.get_signing_serializer(app).dumps(session)}") # Dump session
71
  return redirect(url_for("menu"))
72
  else:
73
  print("Invalid credentials!")