webcodelab commited on
Commit
cef591f
·
verified ·
1 Parent(s): e918291

Update app/routes.py

Browse files
Files changed (1) hide show
  1. app/routes.py +14 -9
app/routes.py CHANGED
@@ -47,6 +47,8 @@ def rank_resumes():
47
 
48
 
49
 
 
 
50
  @auth.route('/register', methods=['GET', 'POST'])
51
  def register():
52
  if request.method == 'POST':
@@ -66,19 +68,21 @@ def register():
66
  db.session.commit()
67
 
68
  # Send verification email
69
- if send_verification_email(email, username, new_user.verification_token):
 
70
  flash('Registration successful! Please check your email to verify your account.')
71
  else:
72
- flash('Registration succeeded, but failed to send verification email.')
 
73
 
74
  new_user.generate_api_key()
75
  db.session.commit()
76
  return redirect(url_for('auth.login'))
77
 
78
  except Exception as e:
79
- print("🔥 Registration error:", e)
80
- traceback.print_exc() # This prints full error to Hugging Face logs
81
- return str(e), 500
82
 
83
  return render_template('register.html')
84
 
@@ -105,7 +109,6 @@ def login():
105
 
106
  return render_template('login.html')
107
 
108
-
109
  @auth.route('/resend-verification', methods=['GET', 'POST'])
110
  def resend_verification():
111
  if request.method == 'POST':
@@ -121,10 +124,12 @@ def resend_verification():
121
  user.generate_verification_token()
122
  db.session.commit()
123
 
124
- if send_verification_email(user.email, user.username, user.verification_token):
 
125
  flash('Verification email resent. Please check your inbox.')
126
  else:
127
- flash('Failed to send verification email. Try again later.')
 
128
  else:
129
  flash('No account found with that email.')
130
 
@@ -133,7 +138,7 @@ def resend_verification():
133
  except Exception as e:
134
  print("🔥 Resend error:", e)
135
  traceback.print_exc()
136
- return str(e), 500
137
 
138
  return render_template('resend_verification.html')
139
 
 
47
 
48
 
49
 
50
+ from flask import jsonify
51
+
52
  @auth.route('/register', methods=['GET', 'POST'])
53
  def register():
54
  if request.method == 'POST':
 
68
  db.session.commit()
69
 
70
  # Send verification email
71
+ result = send_verification_email(email, username, new_user.verification_token)
72
+ if result is True:
73
  flash('Registration successful! Please check your email to verify your account.')
74
  else:
75
+ print("📧 Email error from send_verification_email:", result)
76
+ return jsonify(result), 500 # Shows JSON error in browser
77
 
78
  new_user.generate_api_key()
79
  db.session.commit()
80
  return redirect(url_for('auth.login'))
81
 
82
  except Exception as e:
83
+ print("Registration error:", e)
84
+ traceback.print_exc()
85
+ return jsonify({"error": str(e)}), 500
86
 
87
  return render_template('register.html')
88
 
 
109
 
110
  return render_template('login.html')
111
 
 
112
  @auth.route('/resend-verification', methods=['GET', 'POST'])
113
  def resend_verification():
114
  if request.method == 'POST':
 
124
  user.generate_verification_token()
125
  db.session.commit()
126
 
127
+ result = send_verification_email(user.email, user.username, user.verification_token)
128
+ if result is True:
129
  flash('Verification email resent. Please check your inbox.')
130
  else:
131
+ print("📧 Email error from resend:", result)
132
+ return jsonify(result), 500 # Shows JSON error in browser
133
  else:
134
  flash('No account found with that email.')
135
 
 
138
  except Exception as e:
139
  print("🔥 Resend error:", e)
140
  traceback.print_exc()
141
+ return jsonify({"error": str(e)}), 500
142
 
143
  return render_template('resend_verification.html')
144