From 3c9d0dc91927969d358dbb3b1135eba2230036d3 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Mon, 9 Apr 2018 10:12:15 +0200 Subject: [PATCH] Grant automatically if user has unrevoked token for specified client --- auth.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/auth.py b/auth.py index acf73f1..7dddc7b 100644 --- a/auth.py +++ b/auth.py @@ -218,6 +218,12 @@ def save_token(token, request, *args, **kwargs): def authorize(*args, **kwargs): form = FlaskForm() + if Token.query.filter( + Token.client_id == kwargs.get('client_id'), + Token.user == current_user.username).count(): + # User has unrevoked token already - grant by default + return True + if not form.validate_on_submit(): client_id = kwargs.get('client_id') client = Client.query.filter_by(client_id=client_id).first()