Spaces:
Runtime error
Runtime error
Update app/routes.py
Browse files- app/routes.py +19 -2
app/routes.py
CHANGED
|
@@ -30,6 +30,8 @@ auth = Blueprint('auth', __name__)
|
|
| 30 |
|
| 31 |
@auth.route('/')
|
| 32 |
def landing():
|
|
|
|
|
|
|
| 33 |
return render_template('landing.html')
|
| 34 |
|
| 35 |
|
|
@@ -67,7 +69,6 @@ def rank_resumes():
|
|
| 67 |
except Exception as e:
|
| 68 |
return jsonify({"error": str(e)}), 500
|
| 69 |
|
| 70 |
-
|
| 71 |
@auth.route('/register', methods=['GET', 'POST'])
|
| 72 |
def register():
|
| 73 |
if request.method == 'POST':
|
|
@@ -75,6 +76,19 @@ def register():
|
|
| 75 |
email = request.form.get('email')
|
| 76 |
password = request.form.get('password')
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
hashed_password = generate_password_hash(password)
|
| 79 |
token = str(uuid.uuid4())
|
| 80 |
|
|
@@ -104,9 +118,11 @@ def register():
|
|
| 104 |
return render_template("register.html")
|
| 105 |
|
| 106 |
|
| 107 |
-
|
| 108 |
@auth.route('/login', methods=['GET', 'POST'])
|
| 109 |
def login():
|
|
|
|
|
|
|
|
|
|
| 110 |
if request.method == 'POST':
|
| 111 |
email = request.form['email']
|
| 112 |
password = request.form['password']
|
|
@@ -203,6 +219,7 @@ def resend_verification():
|
|
| 203 |
return render_template('resend_verification.html')
|
| 204 |
|
| 205 |
|
|
|
|
| 206 |
@auth.route('/dashboard')
|
| 207 |
def dashboard():
|
| 208 |
if 'user_id' not in session:
|
|
|
|
| 30 |
|
| 31 |
@auth.route('/')
|
| 32 |
def landing():
|
| 33 |
+
if 'user_id' in session:
|
| 34 |
+
return redirect(url_for('auth.dashboard'))
|
| 35 |
return render_template('landing.html')
|
| 36 |
|
| 37 |
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
return jsonify({"error": str(e)}), 500
|
| 71 |
|
|
|
|
| 72 |
@auth.route('/register', methods=['GET', 'POST'])
|
| 73 |
def register():
|
| 74 |
if request.method == 'POST':
|
|
|
|
| 76 |
email = request.form.get('email')
|
| 77 |
password = request.form.get('password')
|
| 78 |
|
| 79 |
+
if not username or not email or not password:
|
| 80 |
+
flash('Please fill all fields.', 'error')
|
| 81 |
+
return render_template("register.html")
|
| 82 |
+
|
| 83 |
+
# Check if email already exists
|
| 84 |
+
check_response = requests.get(
|
| 85 |
+
f"{SUPABASE_URL}/rest/v1/users?email=eq.{email}",
|
| 86 |
+
headers=HEADERS
|
| 87 |
+
)
|
| 88 |
+
if check_response.status_code == 200 and check_response.json():
|
| 89 |
+
flash('Email already registered. Please log in.', 'warning')
|
| 90 |
+
return redirect(url_for('auth.login'))
|
| 91 |
+
|
| 92 |
hashed_password = generate_password_hash(password)
|
| 93 |
token = str(uuid.uuid4())
|
| 94 |
|
|
|
|
| 118 |
return render_template("register.html")
|
| 119 |
|
| 120 |
|
|
|
|
| 121 |
@auth.route('/login', methods=['GET', 'POST'])
|
| 122 |
def login():
|
| 123 |
+
if 'user_id' in session:
|
| 124 |
+
return redirect(url_for('auth.dashboard'))
|
| 125 |
+
|
| 126 |
if request.method == 'POST':
|
| 127 |
email = request.form['email']
|
| 128 |
password = request.form['password']
|
|
|
|
| 219 |
return render_template('resend_verification.html')
|
| 220 |
|
| 221 |
|
| 222 |
+
|
| 223 |
@auth.route('/dashboard')
|
| 224 |
def dashboard():
|
| 225 |
if 'user_id' not in session:
|