Skip to content

Commit

Permalink
OAuth: Add description
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Nov 7, 2023
1 parent d4b1344 commit f749316
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/blueprints/oauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

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
Expand All @@ -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
Expand Down Expand Up @@ -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"))

Expand Down
6 changes: 6 additions & 0 deletions app/templates/oauth/authorize.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ <h1 class="card-title">{{ self.title() }}</h1>
</div>
</article>
</form>
{% if client.description %}
<div class="alert alert-secondary mt-5 w-50 mx-auto">
<h3 class="mt-0 mb-2">{{ _("About %(title)s", title=client.title) }}</h3>
<p class="mb-0">{{ client.description }}</p>
</div>
{% endif %}
{% if not client.approved %}
<aside class="alert alert-danger mt-5 w-50 mx-auto">
<h3 class="mt-0">{{ _("Application isn't approved yet") }}</h3>
Expand Down
1 change: 1 addition & 0 deletions app/templates/oauth/create_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h3 class="mt-0">{{ _("Application isn't approved yet") }}</h3>
{{ form.hidden_tag() }}

{{ render_field(form.title) }}
{{ render_field(form.description, hint=_("Shown to users when you request access to their account")) }}
{{ render_field(form.redirect_url) }}

{{ render_submit_field(form.submit) }}
Expand Down

0 comments on commit f749316

Please sign in to comment.