Skip to content

Commit

Permalink
remove name attr. from db, changed name of submit to store_image
Browse files Browse the repository at this point in the history
  • Loading branch information
gp-sb committed Nov 13, 2023
1 parent 18c11d9 commit b065a5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Binary file modified Backend/__pycache__/db_access.cpython-39.pyc
Binary file not shown.
19 changes: 8 additions & 11 deletions Backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@



@app.route("/submit", methods=["POST"])
def submit():
@app.route("/store_image", methods=["POST"])
def store_image():
data = request.get_json()

# Validate required fields
Expand Down Expand Up @@ -101,21 +101,20 @@ def login():
return jsonify({"message": str(e)}), 500



@app.route("/register", methods=["POST"])
@app.route("/create_user", methods=["POST"])
def register():
print("received register request")
print(request, request.data)
return jsonify({"message": "No endpoint called register, perhaps you meant: /create_user"})
return jsonify({"message": "No endpoint called create_user, perhaps you meant: /register"})


@app.route("/create_user", methods=["POST"])
def create_user():
@app.route("/register", methods=["POST"])
def register():
#print("BACKEND")
data = request.get_json()

# Validate required fields
required_fields = ["username", "password", "name", "email"]
required_fields = ["username", "password", "email"]
missing_fields = [field for field in required_fields if field not in data]

if missing_fields:
Expand All @@ -127,7 +126,6 @@ def create_user():

username = data["username"]
plain_text_password = data["password"]
name = data["name"]
email = data["email"]

# Hash the password
Expand All @@ -137,8 +135,7 @@ def create_user():
user_data = {
"username": username,
"email": email,
"password": hashed_password,
"name": name
"password": hashed_password
}

# Send the user data with the hashed password to the database access layer
Expand Down
3 changes: 1 addition & 2 deletions Backend/db_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class User(Document):
encrypted_password = StringField(
required=True
)
name = StringField(required=True)


ranking = IntField()

Expand All @@ -48,7 +48,6 @@ def create_user():
user = User(
username=data["username"],
encrypted_password=data["password"],
name=data["name"],
email=data["email"]
)
try:
Expand Down

0 comments on commit b065a5f

Please sign in to comment.