From f74931633cfd66e240f33eb9e7d6b93e1d4a7bf1 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 7 Nov 2023 22:57:19 +0000 Subject: [PATCH] OAuth: Add description --- app/blueprints/oauth/__init__.py | 7 ++++--- app/templates/oauth/authorize.html | 6 ++++++ app/templates/oauth/create_edit.html | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/blueprints/oauth/__init__.py b/app/blueprints/oauth/__init__.py index 8d6f21d4..9b71e249 100644 --- a/app/blueprints/oauth/__init__.py +++ b/app/blueprints/oauth/__init__.py @@ -15,15 +15,15 @@ # along with this program. If not, see . import urllib.parse as urlparse -from typing import Optional from urllib.parse import urlencode +import typing from flask import Blueprint, render_template, redirect, url_for, request, jsonify, abort, make_response, flash from flask_babel import lazy_gettext, gettext from flask_login import current_user, login_required from flask_wtf import FlaskForm from wtforms import StringField, SubmitField, URLField -from wtforms.validators import InputRequired, Length +from wtforms.validators import InputRequired, Length, Optional from app import csrf from app.blueprints.users.settings import get_setting_tabs @@ -33,7 +33,7 @@ bp = Blueprint("oauth", __name__) -def build_redirect_url(url: str, code: str, state: Optional[str]): +def build_redirect_url(url: str, code: str, state: typing.Optional[str]): params = {"code": code} if state is not None: params["state"] = state @@ -165,6 +165,7 @@ def list_clients(username): class OAuthClientForm(FlaskForm): title = StringField(lazy_gettext("Title"), [InputRequired(), Length(5, 30)]) + description = StringField(lazy_gettext("Description"), [Optional()]) redirect_url = URLField(lazy_gettext("Redirect URL"), [InputRequired(), Length(5, 123)]) submit = SubmitField(lazy_gettext("Save")) diff --git a/app/templates/oauth/authorize.html b/app/templates/oauth/authorize.html index 66b1eb16..23b2feb7 100644 --- a/app/templates/oauth/authorize.html +++ b/app/templates/oauth/authorize.html @@ -80,6 +80,12 @@

{{ self.title() }}

+ {% if client.description %} +
+

{{ _("About %(title)s", title=client.title) }}

+

{{ client.description }}

+
+ {% endif %} {% if not client.approved %}