mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
show error message when you try to create a bot using a handle that's already in use
This commit is contained in:
parent
8f6dbfeaf4
commit
48eb730aa2
1 changed files with 9 additions and 1 deletions
|
@ -100,8 +100,15 @@ def bot_create(mysql, cfg, scopes, scopes_pleroma):
|
|||
session['step'] = 3
|
||||
return render_template("bot/create.html", error = error)
|
||||
|
||||
# authentication success!!
|
||||
c = mysql.connection.cursor()
|
||||
c.execute("SELECT COUNT(*) FROM bots WHERE handle = %s", (handle,))
|
||||
count = c.fetchone()
|
||||
if count != None and count[0] == 1:
|
||||
session['error'] = "{} is currently in use by another FediBooks bot.".format(handle)
|
||||
session['step'] = 1
|
||||
return redirect(url_for("render_bot_create"), 303)
|
||||
|
||||
# authentication success!!
|
||||
c.execute("INSERT INTO `credentials` (client_id, client_secret, secret) VALUES (%s, %s, %s)", (session['client_id'], session['client_secret'], session['secret']))
|
||||
credentials_id = c.lastrowid
|
||||
mysql.connection.commit()
|
||||
|
@ -123,6 +130,7 @@ def bot_create(mysql, cfg, scopes, scopes_pleroma):
|
|||
del session['instance_type']
|
||||
del session['client_id']
|
||||
del session['client_secret']
|
||||
|
||||
else:
|
||||
# user is starting a new bot create request
|
||||
session['step'] = 1
|
||||
|
|
Loading…
Reference in a new issue