mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 03:37:28 +01:00
Fix ungraceful error on non-unique OAuthClient title
This commit is contained in:
parent
5a173ee18b
commit
f69bc8fc1e
@ -194,6 +194,10 @@ def create_edit_client(username, id_=None):
|
||||
|
||||
if form.validate_on_submit():
|
||||
if is_new:
|
||||
if OAuthClient.query.filter(OAuthClient.title.ilike(form.title.data.strip())).count() > 0:
|
||||
flash(gettext("An OAuth client with that title already exists. Please choose a new title."), "danger")
|
||||
return render_template("oauth/create_edit.html", user=user, form=form, client=client)
|
||||
|
||||
client = OAuthClient()
|
||||
db.session.add(client)
|
||||
client.owner = user
|
||||
@ -201,6 +205,7 @@ def create_edit_client(username, id_=None):
|
||||
client.secret = random_string(32)
|
||||
client.approved = current_user.rank.at_least(UserRank.EDITOR)
|
||||
|
||||
|
||||
form.populate_obj(client)
|
||||
|
||||
verb = "Created" if is_new else "Edited"
|
||||
|
@ -64,8 +64,8 @@
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
{{ 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.title, hint=_("Titles must be globally unique. For example, what's the name of your application?")) }}
|
||||
{{ render_field(form.description, hint=_("Shown to users when you request access to their account. For example, what does your application do?")) }}
|
||||
{{ render_field(form.redirect_url) }}
|
||||
{{ render_field(form.app_type, hint=_("Where will you store your client_secret?")) }}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user