Switch to using user getattr for configs
This commit is contained in:
parent
594e6f6a9e
commit
67c802c67f
|
@ -33,7 +33,7 @@ def get_bp(login_manager):
|
||||||
remember_me = form.remember.data
|
remember_me = form.remember.data
|
||||||
login_user(u, remember=remember_me)
|
login_user(u, remember=remember_me)
|
||||||
config.logger.info("Logged in user '{}' ({})".format(
|
config.logger.info("Logged in user '{}' ({})".format(
|
||||||
u.get('username'), u.uid))
|
u.username, u.uid))
|
||||||
return redirect(url_for('home.home'))
|
return redirect(url_for('home.home'))
|
||||||
flash("Login not recognized")
|
flash("Login not recognized")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -22,7 +22,7 @@ def get_bp():
|
||||||
@bp.route('/admin/', methods=['GET'])
|
@bp.route('/admin/', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def admin():
|
def admin():
|
||||||
if not current_user.get('admin'):
|
if not current_user.admin:
|
||||||
return redirect(url_for('home.home'))
|
return redirect(url_for('home.home'))
|
||||||
|
|
||||||
with config.json_ro('config.json') as j:
|
with config.json_ro('config.json') as j:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% block title %}Admin | Amanuensis{% endblock %}
|
{% block title %}Admin | Amanuensis{% endblock %}
|
||||||
{% block header %}<h2>Amanuensis - Admin Dashboard</h2>{% endblock %}
|
{% block header %}<h2>Amanuensis - Admin Dashboard</h2>{% endblock %}
|
||||||
|
|
||||||
{% block sb_topline %}<b>{{ current_user.get('displayname') }}</b>{% endblock %}
|
{% block sb_topline %}<b>{{ current_user.displayname }}</b>{% endblock %}
|
||||||
{% block sb_logout %}<a href="{{ url_for('auth.logout') }}">Log out</a>{% endblock %}
|
{% block sb_logout %}<a href="{{ url_for('auth.logout') }}">Log out</a>{% endblock %}
|
||||||
{% block sb_home %}<a href="{{ url_for('home.home') }}">Home</a>{% endblock %}
|
{% block sb_home %}<a href="{{ url_for('home.home') }}">Home</a>{% endblock %}
|
||||||
{% set template_sidebar_rows = [self.sb_topline(), self.sb_logout(), self.sb_home()] %}
|
{% set template_sidebar_rows = [self.sb_topline(), self.sb_logout(), self.sb_home()] %}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
{% block title %}Home | Amanuensis{% endblock %}
|
{% block title %}Home | Amanuensis{% endblock %}
|
||||||
{% block header %}<h2>Amanuensis - Dashboard</h2>{% endblock %}
|
{% block header %}<h2>Amanuensis - Dashboard</h2>{% endblock %}
|
||||||
|
|
||||||
{% block sb_topline %}<b>{{ current_user.get('displayname') }}</b>{% endblock %}
|
{% block sb_topline %}<b>{{ current_user.displayname }}</b>{% endblock %}
|
||||||
{% block sb_logout %}<a href="{{ url_for('auth.logout') }}">Log out</a>{% endblock %}
|
{% block sb_logout %}<a href="{{ url_for('auth.logout') }}">Log out</a>{% endblock %}
|
||||||
{% set template_sidebar_rows = [self.sb_topline(), self.sb_logout()] %}
|
{% set template_sidebar_rows = [self.sb_topline(), self.sb_logout()] %}
|
||||||
|
|
||||||
{% if current_user.get('admin') %}
|
{% if current_user.admin %}
|
||||||
{% block sb_admin %}<a href="{{ url_for('home.admin') }}">Admin</a>{% endblock %}
|
{% block sb_admin %}<a href="{{ url_for('home.admin') }}">Admin</a>{% endblock %}
|
||||||
{% set template_sidebar_rows = template_sidebar_rows + [self.sb_admin()] %}
|
{% set template_sidebar_rows = template_sidebar_rows + [self.sb_admin()] %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -25,9 +25,6 @@ class User(UserMixin):
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self.uid
|
return self.uid
|
||||||
|
|
||||||
def get(self, key):
|
|
||||||
return self.config.get(key)
|
|
||||||
|
|
||||||
def set_password(self, pw):
|
def set_password(self, pw):
|
||||||
h = generate_password_hash(pw)
|
h = generate_password_hash(pw)
|
||||||
with config.json_rw(self.config_path) as j:
|
with config.json_rw(self.config_path) as j:
|
||||||
|
|
Loading…
Reference in New Issue