Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -120,8 +120,14 @@ def login():
|
|
120 |
# Check if Google user exists in the database
|
121 |
user = c.execute("SELECT * FROM users WHERE google_id=?", (google_id,)).fetchone()
|
122 |
if user:
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
access_token = create_access_token(identity=user[1], expires_delta=False)
|
124 |
-
return jsonify({"access_token": access_token, "data_filled":
|
125 |
else:
|
126 |
return jsonify({"message": "User not found"}), 404
|
127 |
|
@@ -130,13 +136,21 @@ def login():
|
|
130 |
return jsonify({"message": "Missing username or password"}), 400
|
131 |
|
132 |
user = c.execute("SELECT * FROM users WHERE username=?", (username,)).fetchone()
|
|
|
133 |
if user and check_password_hash(user[2], password):
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
access_token = create_access_token(identity=username, expires_delta=False)
|
135 |
-
return jsonify({"access_token": access_token, "data_filled":
|
136 |
else:
|
137 |
return jsonify({"message": "Invalid username or password"}), 401
|
138 |
|
139 |
|
|
|
140 |
@app.route('/user_details', methods=['POST'])
|
141 |
@jwt_required()
|
142 |
def add_user_details():
|
|
|
120 |
# Check if Google user exists in the database
|
121 |
user = c.execute("SELECT * FROM users WHERE google_id=?", (google_id,)).fetchone()
|
122 |
if user:
|
123 |
+
# Retrieve data_filled from user_details table
|
124 |
+
user_details = c.execute("SELECT data_filled FROM user_details WHERE user_id=?", (user[0],)).fetchone()
|
125 |
+
if user_details:
|
126 |
+
data_filled = user_details[0]
|
127 |
+
else:
|
128 |
+
data_filled = False # Default value if data not found
|
129 |
access_token = create_access_token(identity=user[1], expires_delta=False)
|
130 |
+
return jsonify({"access_token": access_token, "data_filled": data_filled}), 200
|
131 |
else:
|
132 |
return jsonify({"message": "User not found"}), 404
|
133 |
|
|
|
136 |
return jsonify({"message": "Missing username or password"}), 400
|
137 |
|
138 |
user = c.execute("SELECT * FROM users WHERE username=?", (username,)).fetchone()
|
139 |
+
print(user)
|
140 |
if user and check_password_hash(user[2], password):
|
141 |
+
# Retrieve data_filled from user_details table
|
142 |
+
user_details = c.execute("SELECT data_filled FROM user_details WHERE user_id=?", (user[0],)).fetchone()
|
143 |
+
if user_details:
|
144 |
+
data_filled = user_details[0]
|
145 |
+
else:
|
146 |
+
data_filled = False # Default value if data not found
|
147 |
access_token = create_access_token(identity=username, expires_delta=False)
|
148 |
+
return jsonify({"access_token": access_token, "data_filled": data_filled}), 200
|
149 |
else:
|
150 |
return jsonify({"message": "Invalid username or password"}), 401
|
151 |
|
152 |
|
153 |
+
|
154 |
@app.route('/user_details', methods=['POST'])
|
155 |
@jwt_required()
|
156 |
def add_user_details():
|