remotes/1693045480750635534/spooky-22
Aevann1 2021-08-11 21:46:57 +02:00
parent 19a6626760
commit 326bc0b0da
2 changed files with 45 additions and 3 deletions

View File

@ -165,7 +165,8 @@ def changelogsub(v):
@validate_formkey
def namecolor(v):
color = str(request.form.get("color", "")).strip()
if color not in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']: abort(400)
if color.startswith('#'): color = color[1:]
if len(color) != 6: return render_template("settings_security.html", v=v, error="Invalid color code")
v.namecolor = color
g.db.add(v)
return redirect("/settings/profile")
@ -175,7 +176,8 @@ def namecolor(v):
@validate_formkey
def themecolor(v):
themecolor = str(request.form.get("themecolor", "")).strip()
if themecolor not in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']: abort(400)
if themecolor.startswith('#'): themecolor = themecolor[1:]
if len(themecolor) != 6: return render_template("settings_security.html", v=v, error="Invalid color code")
v.themecolor = themecolor
g.db.add(v)
return redirect("/settings/profile")
@ -185,7 +187,8 @@ def themecolor(v):
@validate_formkey
def titlecolor(v):
titlecolor = str(request.form.get("titlecolor", "")).strip()
if titlecolor not in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']: abort(400)
if titlecolor.startswith('#'): titlecolor = titlecolor[1:]
if len(titlecolor) != 6: return render_template("settings_security.html", v=v, error="Invalid color code")
v.titlecolor = titlecolor
g.db.add(v)
return redirect("/settings/profile")

View File

@ -62,7 +62,20 @@
</form>
</div>
<p class="text-small mb-2">Or type a color code:</p>
<div class="d-flex">
<form action="/settings/themecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{ v.formkey }}">
<input class="form-control" type="text" name="themecolor" id="color-code" value="{% if v.themecolor %}{{v.themecolor}}{% endif %}">
<label class="btn btn-secondary text-capitalize mr-2 mt-2 mb-0">Update<input type="text" for="color-code" onclick="form.submit()" hidden=""></label>
</form>
</div>
</div>
</div>
@ -312,6 +325,19 @@
</form>
</div>
<p class="text-small mb-2">Or type a color code:</p>
<div class="d-flex">
<form action="/settings/namecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{ v.formkey }}">
<input class="form-control" type="text" name="color" id="color-code" value="{% if v.namecolor %}{{v.namecolor}}{% endif %}">
<label class="btn btn-secondary text-capitalize mr-2 mt-2 mb-0">Update<input type="text" for="color-code" onclick="form.submit()" hidden=""></label>
</form>
</div>
</div>
@ -363,6 +389,19 @@
</div>
<p class="text-small mb-2">Or type a color code:</p>
<div class="d-flex">
<form action="/settings/titlecolor" id="color-code-form" method="post">
<input type="hidden" name="formkey" value="{{ v.formkey }}">
<input class="form-control" type="text" name="titlecolor" id="color-code" value="{% if v.titlecolor %}{{v.titlecolor}}{% endif %}">
<label class="btn btn-secondary text-capitalize mr-2 mt-2 mb-0">Update<input type="text" for="color-code" onclick="form.submit()" hidden=""></label>
</form>
</div>
</div>
<div class="body d-lg-flex border-bottom">