Add random URL generation for setup.html

This commit is contained in:
Théophile Diot 2023-11-28 17:03:01 +01:00
parent 1daa4103ff
commit c1e25a64af
No known key found for this signature in database
GPG Key ID: 248FEA4BAE400D06
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,8 @@
from os import _exit, getenv, listdir, sep, urandom
from os.path import basename, dirname, join
from secrets import choice
from string import ascii_letters, digits
from sys import path as sys_path, modules as sys_modules
from pathlib import Path
@ -433,7 +435,7 @@ def setup():
return redirect(url_for("loading", next=url_for("services"), message=f"Creating service {request.form['server_name']} for the web UI"))
return render_template("setup.html", username=getenv("ADMIN_USERNAME", ""), password=getenv("ADMIN_PASSWORD", ""))
return render_template("setup.html", username=getenv("ADMIN_USERNAME", ""), password=getenv("ADMIN_PASSWORD", ""), random_url=f"/{''.join(choice(ascii_letters + digits) for _ in range(10))}")
@app.route("/home")

View File

@ -1320,6 +1320,7 @@
name="ui_url"
class="col-span-12 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-300 disabled:opacity-75 focus:valid:border-green-500 focus:invalid:border-red-500 outline-none focus:border-primary text-sm leading-5.6 ease block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-4 py-2 font-normal text-gray-700 transition-all placeholder:text-gray-500"
placeholder="/admin"
value="{{ random_url }}"
required
/>
</div>