diff --git a/app/blueprints/oauth/__init__.py b/app/blueprints/oauth/__init__.py index 02368095..6a46b839 100644 --- a/app/blueprints/oauth/__init__.py +++ b/app/blueprints/oauth/__init__.py @@ -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" diff --git a/app/templates/oauth/create_edit.html b/app/templates/oauth/create_edit.html index 862a4711..4cdf67c9 100644 --- a/app/templates/oauth/create_edit.html +++ b/app/templates/oauth/create_edit.html @@ -64,8 +64,8 @@