diff --git a/app.py b/app.py index 06d50c2..eb33b28 100755 --- a/app.py +++ b/app.py @@ -142,10 +142,11 @@ def handler_403(msg): # Admin routes @app.route('/dashboard') def admin_root(): + user = User.query.filter_by(username=session.get('user')).one_or_404() if 'admin' in session: - return render_template("admin.html", user=session.get("admin")) + return render_template("admin.html", user=user) if 'user' in session: - return render_template("user.html", user=session.get("user")) + return render_template("user.html", user=user) return User.authorize_or_redirect(admin=False) or "" @@ -192,6 +193,16 @@ def accounts_edit(): return render_template("account_edit.html", user=object_as_dict(user), success=True) +@app.route('/accounts/view') +def accounts_all(): + if "admin" not in session: + abort(403) + users = [object_as_dict(u) for u in User.query.all()] + for u in users: + u.pop("password") + return jsonify(users) + + @app.route('/accounts/view/') def accounts_view(id): user = User.query.filter_by(id=id).one_or_404() diff --git a/templates/admin.html b/templates/admin.html index 2ea4d67..0b9b0fe 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -4,9 +4,8 @@ href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css"> -

Admin Dashboard

+

Welcome, {{user.name | safe}} (Admin)

-

Logged in as {{user}}

-

Admin Authentication

+

Authentication-Related

- Since there is now an admin, only admins can create new admin accounts. You can do so through the /admin/create - route. + Only Admins are capable of creating new admins. +
+ + + + + +

API Routes