Fix login
Remove comment
This commit is contained in:
parent
02d99c0fb1
commit
7e1f86f1c5
1 changed files with 10 additions and 6 deletions
|
@ -34,10 +34,15 @@ async def http_exception_handler(request, exc):
|
|||
@app.post("/api/v1/login")
|
||||
async def login(username: str = Form(), password: str = Form(), version: str = Form()):
|
||||
"""User login"""
|
||||
# FIXME Add login
|
||||
hook.execute_hooks("player_login", username=username)
|
||||
|
||||
return {"token": username + ":" + password, "userId": 1}
|
||||
auth = db.auth_check(username + ":" + password)
|
||||
if not auth[0]:
|
||||
if auth[1] == "nouser":
|
||||
raise HTTPException(404, detail="User not found.")
|
||||
elif auth[1] == "wrongpass":
|
||||
raise HTTPException(403, detail="Password is incorrect.")
|
||||
else:
|
||||
return {"token": username + ":" + password, "userId": auth[1]["ID"]}
|
||||
|
||||
|
||||
@app.put("/api/v1/user")
|
||||
|
@ -79,7 +84,6 @@ async def refresh_login(Authorization: Union[str, None] = Header(default=None)):
|
|||
@app.get("/api/v1/user/{user_id}")
|
||||
async def get_user(user_id: int):
|
||||
"""Returns specified user's profile."""
|
||||
# FIXME use database
|
||||
query = db.user_collection.find_one({"ID": user_id})
|
||||
del query["Password"]
|
||||
return types.User(**query)
|
||||
|
@ -198,7 +202,7 @@ async def stopMapPlay(
|
|||
|
||||
updateQuery = db.maps_collection.update_one(
|
||||
{"ID": mapID},
|
||||
{"$pull": {"Leaderboard": {"UserID": userData.ID}}
|
||||
{"$pull": {"Leaderboard": {"UserID": userData.ID}},
|
||||
}
|
||||
)
|
||||
updateQuery = db.maps_collection.update_one(
|
||||
|
@ -283,7 +287,7 @@ async def upload_map(
|
|||
print(authcheck)
|
||||
userData = types.User(**authcheck[1])
|
||||
ID = len(list(db.maps_collection.find({}))) + 1
|
||||
MapCode = db.id_to_mapcode(ID) # FIXME Add mapcodes correctly
|
||||
MapCode = db.id_to_mapcode(ID)
|
||||
db.maps_collection.insert_one(
|
||||
{
|
||||
**types.Map(
|
||||
|
|
Loading…
Reference in a new issue