don't use "error"
This commit is contained in:
parent
7ec3a0b4c0
commit
4d4427c892
24
main
24
main
|
@ -38,7 +38,7 @@ def get_user(id):
|
||||||
(id,)).fetchone()
|
(id,)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post is None:
|
if post is None:
|
||||||
return "error"
|
return None
|
||||||
return post
|
return post
|
||||||
|
|
||||||
def get_note(id):
|
def get_note(id):
|
||||||
|
@ -47,7 +47,7 @@ def get_note(id):
|
||||||
(id,)).fetchone()
|
(id,)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post is None:
|
if post is None:
|
||||||
return "error"
|
return None
|
||||||
return post
|
return post
|
||||||
|
|
||||||
def get_space(id):
|
def get_space(id):
|
||||||
|
@ -75,7 +75,7 @@ def get_session(id):
|
||||||
(id,)).fetchone()
|
(id,)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post is None:
|
if post is None:
|
||||||
return "error"
|
return None
|
||||||
return post
|
return post
|
||||||
|
|
||||||
def get_session_from_sessionid(id):
|
def get_session_from_sessionid(id):
|
||||||
|
@ -84,7 +84,7 @@ def get_session_from_sessionid(id):
|
||||||
(id,)).fetchone()
|
(id,)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post is None:
|
if post is None:
|
||||||
return "error"
|
return None
|
||||||
return post
|
return post
|
||||||
|
|
||||||
def check_username_taken(username):
|
def check_username_taken(username):
|
||||||
|
@ -93,7 +93,7 @@ def check_username_taken(username):
|
||||||
(username.lower(),)).fetchone()
|
(username.lower(),)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post is None:
|
if post is None:
|
||||||
return "error"
|
return None
|
||||||
return post["id"]
|
return post["id"]
|
||||||
|
|
||||||
# Disable CORS
|
# Disable CORS
|
||||||
|
@ -170,7 +170,7 @@ async def apisignup():
|
||||||
if len(password) < 14:
|
if len(password) < 14:
|
||||||
return {}, 422
|
return {}, 422
|
||||||
|
|
||||||
if not check_username_taken(username) == "error":
|
if not check_username_taken(username) == None:
|
||||||
return {}, 409
|
return {}, 409
|
||||||
|
|
||||||
hashedpassword = generate_password_hash(password)
|
hashedpassword = generate_password_hash(password)
|
||||||
|
@ -207,7 +207,7 @@ async def apilogin():
|
||||||
|
|
||||||
check_username_thing = check_username_taken(username)
|
check_username_thing = check_username_taken(username)
|
||||||
|
|
||||||
if check_username_thing == "error":
|
if check_username_thing == None:
|
||||||
return {}, 401
|
return {}, 401
|
||||||
|
|
||||||
userID = check_username_taken(username)
|
userID = check_username_taken(username)
|
||||||
|
@ -335,7 +335,7 @@ async def apireadnote():
|
||||||
|
|
||||||
note = get_note(noteId)
|
note = get_note(noteId)
|
||||||
|
|
||||||
if (note != "error"):
|
if (note != None):
|
||||||
if (user["id"] == note["creator"]):
|
if (user["id"] == note["creator"]):
|
||||||
contenttemplate = {
|
contenttemplate = {
|
||||||
"content": note["content"]
|
"content": note["content"]
|
||||||
|
@ -363,7 +363,7 @@ async def apieditnote():
|
||||||
if get_space(user["id"]) + len(content.encode("utf-8")) > int(MAX_STORAGE):
|
if get_space(user["id"]) + len(content.encode("utf-8")) > int(MAX_STORAGE):
|
||||||
return {}, 418
|
return {}, 418
|
||||||
|
|
||||||
if (note != "error"):
|
if (note != None):
|
||||||
if (user["id"] == note["creator"]):
|
if (user["id"] == note["creator"]):
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
conn.execute("UPDATE notes SET content = ?, edited = ? WHERE id = ?", (content, str(time.time()), noteId))
|
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):
|
if get_space(user["id"]) + len(content.encode("utf-8")) > int(MAX_STORAGE):
|
||||||
return {}, 418
|
return {}, 418
|
||||||
|
|
||||||
if (note != "error"):
|
if (note != None):
|
||||||
if (user["id"] == note["creator"]):
|
if (user["id"] == note["creator"]):
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
conn.execute("UPDATE notes SET title = ?, edited = ? WHERE id = ?", (content, str(time.time()), noteId))
|
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)
|
note = get_note(noteId)
|
||||||
|
|
||||||
if (note != "error"):
|
if (note != None):
|
||||||
if (user["id"] == note["creator"]):
|
if (user["id"] == note["creator"]):
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
conn.execute("DELETE FROM notes WHERE id = ?", (noteId,))
|
conn.execute("DELETE FROM notes WHERE id = ?", (noteId,))
|
||||||
|
@ -495,7 +495,7 @@ async def apisessionsremove():
|
||||||
|
|
||||||
session = get_session_from_sessionid(sessionId)
|
session = get_session_from_sessionid(sessionId)
|
||||||
|
|
||||||
if (session != "error"):
|
if (session != None):
|
||||||
if (user["id"] == session["id"]):
|
if (user["id"] == session["id"]):
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
conn.execute("DELETE FROM sessions WHERE sessionid = ?", (session["sessionid"],))
|
conn.execute("DELETE FROM sessions WHERE sessionid = ?", (session["sessionid"],))
|
||||||
|
|
Loading…
Reference in New Issue