Test for server side

This commit is contained in:
Tracker-Friendly 2024-04-18 08:52:59 +01:00
parent b9b02d5e7d
commit a703889319
1 changed files with 9 additions and 8 deletions

17
main
View File

@ -248,14 +248,15 @@ async def apiopeniduserinfo():
return datatemplate return datatemplate
@app.route("/api/auth", methods=("GET", "POST")) @app.route("/api/auth", methods=("GET"))
async def apiauthenticate(): async def apiauthenticate():
if request.method == "POST": if request.method == "GET":
data = await request.get_json() secretKey = request.headers.get["secretKey"]
secretKey = data["secretKey"] appId = request.args.get["client_id"]
appId = data["appId"] code = request.args.get["code_challenge"]
code = data["code"] codemethod = request.args.get["code_challenge_method"]
codemethod = data["codemethod"] redirect = request.args.get["redirect_uri"]
state = request.args.get["state"]
userCookie = get_session(secretKey) userCookie = get_session(secretKey)
user = get_user(userCookie["id"]) user = get_user(userCookie["id"])
@ -299,7 +300,7 @@ async def apiauthenticate():
conn.close() conn.close()
if secretkey: if secretkey:
return secretkey, 200 return redirect(redirect_uri + "?code=" + secretkey + "&state=" + state), 200
else: else:
return {}, 400 return {}, 400