Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -45,7 +45,6 @@ c.execute('''CREATE TABLE IF NOT EXISTS user_mentor
|
|
| 45 |
FOREIGN KEY(user_id) REFERENCES users(id))''')
|
| 46 |
conn.commit()
|
| 47 |
|
| 48 |
-
# Endpoint for user registration and Google signup
|
| 49 |
@app.route('/register', methods=['POST'])
|
| 50 |
def register():
|
| 51 |
data = request.get_json()
|
|
@@ -53,6 +52,8 @@ def register():
|
|
| 53 |
password = data.get('password')
|
| 54 |
google_token = data.get('google_token')
|
| 55 |
|
|
|
|
|
|
|
| 56 |
if google_token:
|
| 57 |
# User signing up with Google
|
| 58 |
resp = google.get("/oauth2/v2/userinfo")
|
|
@@ -73,6 +74,8 @@ def register():
|
|
| 73 |
if not username or not password:
|
| 74 |
return jsonify({"message": "Missing username or password"}), 400
|
| 75 |
|
|
|
|
|
|
|
| 76 |
hashed_password = generate_password_hash(password)
|
| 77 |
try:
|
| 78 |
c.execute("INSERT INTO users (username, password) VALUES (?, ?)", (username, hashed_password))
|
|
@@ -82,6 +85,8 @@ def register():
|
|
| 82 |
except sqlite3.IntegrityError:
|
| 83 |
return jsonify({"message": "Username already exists"}), 400
|
| 84 |
|
|
|
|
|
|
|
| 85 |
# Endpoint for user login and Google login
|
| 86 |
@app.route('/login', methods=['POST'])
|
| 87 |
def login():
|
|
|
|
| 45 |
FOREIGN KEY(user_id) REFERENCES users(id))''')
|
| 46 |
conn.commit()
|
| 47 |
|
|
|
|
| 48 |
@app.route('/register', methods=['POST'])
|
| 49 |
def register():
|
| 50 |
data = request.get_json()
|
|
|
|
| 52 |
password = data.get('password')
|
| 53 |
google_token = data.get('google_token')
|
| 54 |
|
| 55 |
+
print("Username:", username) # Debug print
|
| 56 |
+
|
| 57 |
if google_token:
|
| 58 |
# User signing up with Google
|
| 59 |
resp = google.get("/oauth2/v2/userinfo")
|
|
|
|
| 74 |
if not username or not password:
|
| 75 |
return jsonify({"message": "Missing username or password"}), 400
|
| 76 |
|
| 77 |
+
print("Type of username:", type(username)) # Debug print
|
| 78 |
+
|
| 79 |
hashed_password = generate_password_hash(password)
|
| 80 |
try:
|
| 81 |
c.execute("INSERT INTO users (username, password) VALUES (?, ?)", (username, hashed_password))
|
|
|
|
| 85 |
except sqlite3.IntegrityError:
|
| 86 |
return jsonify({"message": "Username already exists"}), 400
|
| 87 |
|
| 88 |
+
|
| 89 |
+
|
| 90 |
# Endpoint for user login and Google login
|
| 91 |
@app.route('/login', methods=['POST'])
|
| 92 |
def login():
|