|
|
@ -24,8 +24,8 @@ def index():
|
|
|
|
def is_login_ok(username, password):
|
|
|
|
def is_login_ok(username, password):
|
|
|
|
hashed = hashlib.sha256(password.encode()).hexdigest().upper()
|
|
|
|
hashed = hashlib.sha256(password.encode()).hexdigest().upper()
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
app.config['CONFIG'].get(ConfigParameter.WEB_USERNAME) == username
|
|
|
|
app.config["CONFIG"].get(ConfigParameter.WEB_USERNAME) == username
|
|
|
|
and app.config['CONFIG'].get(ConfigParameter.WEB_PASSWORD) == hashed
|
|
|
|
and app.config["CONFIG"].get(ConfigParameter.WEB_PASSWORD) == hashed
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,7 +41,9 @@ def login():
|
|
|
|
flash("Identifiant ou mot de passe incorrect")
|
|
|
|
flash("Identifiant ou mot de passe incorrect")
|
|
|
|
return redirect("/web/login")
|
|
|
|
return redirect("/web/login")
|
|
|
|
# GET
|
|
|
|
# GET
|
|
|
|
return render_template("login_" + app.config['CONFIG'].get(ConfigParameter.LANG) + ".html")
|
|
|
|
return render_template(
|
|
|
|
|
|
|
|
"login_" + app.config["CONFIG"].get(ConfigParameter.LANG) + ".html"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/web/logout", methods=["GET"])
|
|
|
|
@app.route("/web/logout", methods=["GET"])
|
|
|
@ -54,7 +56,7 @@ def logout():
|
|
|
|
def admin_homepage():
|
|
|
|
def admin_homepage():
|
|
|
|
if not (
|
|
|
|
if not (
|
|
|
|
"user" in session
|
|
|
|
"user" in session
|
|
|
|
and session["user"] == app.config['CONFIG'].get(ConfigParameter.WEB_USERNAME)
|
|
|
|
and session["user"] == app.config["CONFIG"].get(ConfigParameter.WEB_USERNAME)
|
|
|
|
):
|
|
|
|
):
|
|
|
|
# TODO localization
|
|
|
|
# TODO localization
|
|
|
|
flash("Vous avez été déconnecté.")
|
|
|
|
flash("Vous avez été déconnecté.")
|
|
|
@ -62,9 +64,9 @@ def admin_homepage():
|
|
|
|
|
|
|
|
|
|
|
|
comments = dao.find_not_published_comments()
|
|
|
|
comments = dao.find_not_published_comments()
|
|
|
|
return render_template(
|
|
|
|
return render_template(
|
|
|
|
"admin_" + app.config['CONFIG'].get(ConfigParameter.LANG) + ".html",
|
|
|
|
"admin_" + app.config["CONFIG"].get(ConfigParameter.LANG) + ".html",
|
|
|
|
comments=comments,
|
|
|
|
comments=comments,
|
|
|
|
baseurl=app.config['CONFIG'].get(ConfigParameter.SITE_URL),
|
|
|
|
baseurl=app.config["CONFIG"].get(ConfigParameter.SITE_URL),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +78,7 @@ def admin_action():
|
|
|
|
flash("Commentaire introuvable")
|
|
|
|
flash("Commentaire introuvable")
|
|
|
|
elif request.form.get("action") == "APPROVE":
|
|
|
|
elif request.form.get("action") == "APPROVE":
|
|
|
|
dao.publish_comment(comment)
|
|
|
|
dao.publish_comment(comment)
|
|
|
|
app.config['RSS'].generate()
|
|
|
|
app.config["RSS"].generate()
|
|
|
|
# TODO localization
|
|
|
|
# TODO localization
|
|
|
|
flash("Commentaire publié")
|
|
|
|
flash("Commentaire publié")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|