Added user management
This commit is contained in:
parent
8e2d2f5174
commit
1f8c406bd0
10
shop.py
10
shop.py
@ -73,7 +73,7 @@ def handle_data():
|
||||
user_id = request.form['updatepass']
|
||||
newpass = request.form['newpass']
|
||||
db.update_pass(user_id, newpass)
|
||||
return redirect(url_for("admin"))
|
||||
return redirect(url_for("index"))
|
||||
|
||||
if "logout" in request.form:
|
||||
session.clear()
|
||||
@ -92,13 +92,18 @@ def handle_data():
|
||||
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@application.route("/useracc")
|
||||
def useracc():
|
||||
|
||||
return render_template("useracc.html")
|
||||
|
||||
@application.route("/admin")
|
||||
def admin():
|
||||
if session.get('id') is None:
|
||||
data = {"title":"Login"}
|
||||
return render_template("auth.html", data=data)
|
||||
elif session.get('isAdmin') == 0:
|
||||
return redirect(url_for("index"))
|
||||
return redirect(url_for("useracc"))
|
||||
|
||||
#get a list of users
|
||||
userList = db.get_users()
|
||||
@ -110,3 +115,4 @@ def admin():
|
||||
if __name__ == '__main__':
|
||||
db.doesTableExist()
|
||||
application.run(host="0.0.0.0")
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
{% include "header.html" %}
|
||||
<div style="width: 90%; display: flex; justify-content: center;">
|
||||
<a href="/">
|
||||
<button onclick="window.location='admin'" class="btn btn-secondary"><i style="padding-top: 3px;"
|
||||
class="material-icons">
|
||||
home
|
||||
</i></button></a>
|
||||
<div >
|
||||
<h1> Welcome {{session["username"].title()}} you can change your password below</h1>
|
||||
<div >
|
||||
<form action="/post" method="POST"><input style="display: inline;"
|
||||
class="form-control" type="text" name="newpass" id="addbox"><button
|
||||
class="btn btn-secondary" type="submit" name="updatepass" value="{{session['id']}}"> Change
|
||||
Password </button></form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "footer.html" %}
|
||||
Loading…
x
Reference in New Issue
Block a user