Grant automatically if user has unrevoked token for specified client

master
informatic 2018-04-09 10:12:15 +02:00
parent bebd9b0db8
commit 3c9d0dc919
1 changed files with 6 additions and 0 deletions

View File

@ -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()