forked from Github-Mirrors/canaille
fix: SMTP feature can be disabled again
This commit is contained in:
parent
43f9f328a5
commit
3fb5d0149d
5 changed files with 9 additions and 9 deletions
|
@ -4,7 +4,7 @@ class Features:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_smtp(self):
|
def has_smtp(self):
|
||||||
return "SMTP" in self.app.config["CANAILLE"]
|
return bool(self.app.config["CANAILLE"]["SMTP"])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_oidc(self):
|
def has_oidc(self):
|
||||||
|
|
|
@ -75,7 +75,7 @@ def index():
|
||||||
|
|
||||||
@bp.route("/join", methods=("GET", "POST"))
|
@bp.route("/join", methods=("GET", "POST"))
|
||||||
def join():
|
def join():
|
||||||
if not current_app.config["CANAILLE"]["ENABLE_REGISTRATION"]:
|
if not current_app.features.has_registration:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
if not current_app.config["CANAILLE"]["EMAIL_CONFIRMATION"]:
|
if not current_app.config["CANAILLE"]["EMAIL_CONFIRMATION"]:
|
||||||
|
@ -235,8 +235,8 @@ def registration(data=None, hash=None):
|
||||||
if not data:
|
if not data:
|
||||||
payload = None
|
payload = None
|
||||||
if (
|
if (
|
||||||
not current_app.config["CANAILLE"]["ENABLE_REGISTRATION"]
|
not current_app.features.has_registration
|
||||||
or current_app.config["CANAILLE"]["EMAIL_CONFIRMATION"]
|
or current_app.features.has_email_confirmation
|
||||||
):
|
):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ def test_confirmation_unset_smtp_disabled_email_editable(
|
||||||
"""If email confirmation is unset and no SMTP server has been configured,
|
"""If email confirmation is unset and no SMTP server has been configured,
|
||||||
then email confirmation cannot be enabled, thus users must be able to pick
|
then email confirmation cannot be enabled, thus users must be able to pick
|
||||||
any email."""
|
any email."""
|
||||||
del testclient.app.config["CANAILLE"]["SMTP"]
|
testclient.app.config["CANAILLE"]["SMTP"] = None
|
||||||
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = None
|
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = None
|
||||||
|
|
||||||
res = testclient.get("/profile/user")
|
res = testclient.get("/profile/user")
|
||||||
|
@ -61,7 +61,7 @@ def test_confirmation_enabled_smtp_disabled_readonly(testclient, backend, logged
|
||||||
|
|
||||||
In doubt, users cannot edit their emails.
|
In doubt, users cannot edit their emails.
|
||||||
"""
|
"""
|
||||||
del testclient.app.config["CANAILLE"]["SMTP"]
|
testclient.app.config["CANAILLE"]["SMTP"] = None
|
||||||
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = True
|
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = True
|
||||||
|
|
||||||
res = testclient.get("/profile/user")
|
res = testclient.get("/profile/user")
|
||||||
|
@ -101,7 +101,7 @@ def test_confirmation_enabled_smtp_disabled_admin_editable(
|
||||||
"""Administrators should be able to edit user email addresses, even when
|
"""Administrators should be able to edit user email addresses, even when
|
||||||
email confirmation is enabled and SMTP is disabled."""
|
email confirmation is enabled and SMTP is disabled."""
|
||||||
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = True
|
testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = True
|
||||||
del testclient.app.config["CANAILLE"]["SMTP"]
|
testclient.app.config["CANAILLE"]["SMTP"] = None
|
||||||
|
|
||||||
res = testclient.get("/profile/user")
|
res = testclient.get("/profile/user")
|
||||||
assert "readonly" not in res.form["emails-0"].attrs
|
assert "readonly" not in res.form["emails-0"].attrs
|
||||||
|
|
|
@ -292,7 +292,7 @@ def test_unavailable_if_no_smtp(testclient, logged_admin):
|
||||||
res.mustcontain("Invite")
|
res.mustcontain("Invite")
|
||||||
testclient.get("/invite")
|
testclient.get("/invite")
|
||||||
|
|
||||||
del testclient.app.config["CANAILLE"]["SMTP"]
|
testclient.app.config["CANAILLE"]["SMTP"] = None
|
||||||
|
|
||||||
res = testclient.get("/users")
|
res = testclient.get("/users")
|
||||||
res.mustcontain(no="Invite")
|
res.mustcontain(no="Invite")
|
||||||
|
|
|
@ -78,7 +78,7 @@ def test_unavailable_if_no_smtp(testclient, user):
|
||||||
|
|
||||||
testclient.get("/reset", status=200)
|
testclient.get("/reset", status=200)
|
||||||
|
|
||||||
del testclient.app.config["CANAILLE"]["SMTP"]
|
testclient.app.config["CANAILLE"]["SMTP"] = None
|
||||||
|
|
||||||
res = testclient.get("/login")
|
res = testclient.get("/login")
|
||||||
res.mustcontain(no="Forgotten password")
|
res.mustcontain(no="Forgotten password")
|
||||||
|
|
Loading…
Reference in a new issue