Use headers instead of body for token
Now the endpoints follow HTTP rules in GET requests
This commit is contained in:
6
main.py
6
main.py
@@ -89,7 +89,7 @@ def checkChatPermission(token, chatId, permission):
|
||||
@app.route('/api/user/chats', methods = ['GET'])
|
||||
def getUserChats():
|
||||
# Get user auth token
|
||||
token = request.json['token']
|
||||
token = request.headers['token']
|
||||
a, userId = checkUserPermission(token, True)
|
||||
if (a == True):
|
||||
returnedChats = list(chatCollection.find({'permissions.' + userId : "view"}))
|
||||
@@ -108,7 +108,7 @@ def getUserChats():
|
||||
@app.route('/api/chat/<_id>/details/<details>', methods = ['GET', 'POST'])
|
||||
def getChatHistory(_id, details):
|
||||
# Get user auth token
|
||||
token = request.json['token']
|
||||
token = request.headers['token']
|
||||
a, userId = checkChatPermission(token, _id, True)
|
||||
if (a == True):
|
||||
# If the user is trying to GET data
|
||||
@@ -154,7 +154,7 @@ def getChatHistory(_id, details):
|
||||
@app.route('/api/chat/create', methods = ['POST'])
|
||||
def createChat():
|
||||
# Get user auth token
|
||||
token = request.json['token']
|
||||
token = request.headers['token']
|
||||
a, userId = checkUserPermission(token, "createChat")
|
||||
if (a == True):
|
||||
name = request.json['name']
|
||||
|
||||
Reference in New Issue
Block a user