diff --git a/main b/main index 9222e51..cc18806 100644 --- a/main +++ b/main @@ -38,7 +38,7 @@ def get_user(id): (id,)).fetchone() conn.close() if post is None: - return "error" + return None return post def get_note(id): @@ -47,7 +47,7 @@ def get_note(id): (id,)).fetchone() conn.close() if post is None: - return "error" + return None return post def get_space(id): @@ -75,7 +75,7 @@ def get_session(id): (id,)).fetchone() conn.close() if post is None: - return "error" + return None return post def get_session_from_sessionid(id): @@ -84,7 +84,7 @@ def get_session_from_sessionid(id): (id,)).fetchone() conn.close() if post is None: - return "error" + return None return post def check_username_taken(username): @@ -93,7 +93,7 @@ def check_username_taken(username): (username.lower(),)).fetchone() conn.close() if post is None: - return "error" + return None return post["id"] # Disable CORS @@ -170,7 +170,7 @@ async def apisignup(): if len(password) < 14: return {}, 422 - if not check_username_taken(username) == "error": + if not check_username_taken(username) == None: return {}, 409 hashedpassword = generate_password_hash(password) @@ -207,7 +207,7 @@ async def apilogin(): check_username_thing = check_username_taken(username) - if check_username_thing == "error": + if check_username_thing == None: return {}, 401 userID = check_username_taken(username) @@ -335,7 +335,7 @@ async def apireadnote(): note = get_note(noteId) - if (note != "error"): + if (note != None): if (user["id"] == note["creator"]): contenttemplate = { "content": note["content"] @@ -363,7 +363,7 @@ async def apieditnote(): if get_space(user["id"]) + len(content.encode("utf-8")) > int(MAX_STORAGE): return {}, 418 - if (note != "error"): + if (note != None): if (user["id"] == note["creator"]): conn = get_db_connection() conn.execute("UPDATE notes SET content = ?, edited = ? WHERE id = ?", (content, str(time.time()), noteId)) @@ -393,7 +393,7 @@ async def apieditnotetitle(): if get_space(user["id"]) + len(content.encode("utf-8")) > int(MAX_STORAGE): return {}, 418 - if (note != "error"): + if (note != None): if (user["id"] == note["creator"]): conn = get_db_connection() conn.execute("UPDATE notes SET title = ?, edited = ? WHERE id = ?", (content, str(time.time()), noteId)) @@ -419,7 +419,7 @@ async def apiremovenote(): note = get_note(noteId) - if (note != "error"): + if (note != None): if (user["id"] == note["creator"]): conn = get_db_connection() conn.execute("DELETE FROM notes WHERE id = ?", (noteId,)) @@ -495,7 +495,7 @@ async def apisessionsremove(): session = get_session_from_sessionid(sessionId) - if (session != "error"): + if (session != None): if (user["id"] == session["id"]): conn = get_db_connection() conn.execute("DELETE FROM sessions WHERE sessionid = ?", (session["sessionid"],))