From 4a9594a15670785751a6d82d99a408a27b6e8c2e Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 17 Jun 2023 12:47:09 -0400 Subject: use attribute external_auth --- newspipe/templates/admin/dashboard.html | 2 ++ newspipe/templates/profile.html | 4 ++-- newspipe/web/forms.py | 3 ++- newspipe/web/views/views.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/newspipe/templates/admin/dashboard.html b/newspipe/templates/admin/dashboard.html index db56be25..370ab702 100644 --- a/newspipe/templates/admin/dashboard.html +++ b/newspipe/templates/admin/dashboard.html @@ -9,6 +9,7 @@ {{ _('Nickname') }} {{ _('Member since') }} {{ _('Last seen') }} + {{ _('External auth') }} {{ _('Actions') }} @@ -26,6 +27,7 @@ {{ user.date_created | datetime }} {{ user.last_seen | datetime }} + {{ user.external_auth | safe }} {% if user.id != current_user.id %} diff --git a/newspipe/templates/profile.html b/newspipe/templates/profile.html index 6cb59ed5..68ecab11 100644 --- a/newspipe/templates/profile.html +++ b/newspipe/templates/profile.html @@ -23,11 +23,11 @@ {{ form.nickname.label }} {{ form.nickname(class_="form-control") }} {% for error in form.nickname.errors %} {{ error }}
{% endfor %} - {{ form.password.label }} + {% if not user.external_auth %}{{ form.password.label }} {{ form.password(class_="form-control") }} {% for error in form.password.errors %} {{ error }}
{% endfor %} {{ form.password_conf.label }} - {{ form.password_conf(class_="form-control") }} {% for error in form.password_conf.errors %} {{ error }}
{% endfor %} + {{ form.password_conf(class_="form-control") }} {% for error in form.password_conf.errors %} {{ error }}
{% endfor %}{% else%}{% for error in form.password.errors %} {{ error }}
{% endfor %}No password management for auth type {{ user.external_auth }}{% endif %}
diff --git a/newspipe/web/forms.py b/newspipe/web/forms.py index 4cd552e0..7a245b94 100644 --- a/newspipe/web/forms.py +++ b/newspipe/web/forms.py @@ -173,6 +173,7 @@ class SigninForm(RedirectForm): automatic_crawling=True, is_admin=False, is_active=True, + external_auth="ldap", ) if user: validated = True @@ -199,7 +200,7 @@ class SigninForm(RedirectForm): self.password.errors.append("Wrong password") validated = False else: - self.password.errors.append("External auth unavailable. Contact the admin.") + self.password.errors.append("External auth {user.external_auth} unavailable. Contact the admin.") validated = False self.user = user return validated diff --git a/newspipe/web/views/views.py b/newspipe/web/views/views.py index 7ff2a2e4..bb7bff2f 100644 --- a/newspipe/web/views/views.py +++ b/newspipe/web/views/views.py @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) @current_app.errorhandler(401) def authentication_required(error): - if application.conf["API_ROOT"] in request.url: + if application.config["API_ROOT"] in request.url: return error flash(gettext("Authentication required."), "info") return redirect(url_for("login")) @@ -33,7 +33,7 @@ def authentication_required(error): @current_app.errorhandler(403) def authentication_failed(error): - if application.conf["API_ROOT"] in request.url: + if application.config["API_ROOT"] in request.url: return error flash(gettext("Forbidden."), "danger") return redirect(url_for("login")) -- cgit