From 3867885b89dfcdc08e471fcd7c0314583b3cb691 Mon Sep 17 00:00:00 2001 From: ka Date: Sat, 15 Jun 2024 14:20:13 -0300 Subject: [PATCH] feat: let flask manage invalid methods on routes --- ajusta_bling/web/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ajusta_bling/web/__init__.py b/ajusta_bling/web/__init__.py index 09f3d9a..4b289cc 100644 --- a/ajusta_bling/web/__init__.py +++ b/ajusta_bling/web/__init__.py @@ -15,7 +15,7 @@ app = Flask(__name__) app.secret_key = "#^A549639t5@#&$p" db: Database | None = None -@app.route('/auth') +@app.get('/auth') def auth(): session["state"] = secrets.token_urlsafe(16) @@ -26,11 +26,8 @@ def auth(): "state": session["state"] }) -@app.route('/callback', methods = ["GET"]) +@app.get('/callback') def callback(): - if request.method != "GET": - return "I curse you!", 403 - if request.args.get("state") != session.pop("state", "fartnugget"): return "I banish thee, to the state of Ohio", 403