mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Use a flag rather than a new route for the public policy
This also means that the template now has optional parameters, which will need to be documented somehow.
This commit is contained in:
parent
f9d34a763c
commit
537d0b7b36
@ -471,7 +471,7 @@ class AuthHandler(BaseHandler):
|
|||||||
"policies": [{
|
"policies": [{
|
||||||
"name": "Privacy Policy",
|
"name": "Privacy Policy",
|
||||||
"version": self.hs.config.user_consent_version,
|
"version": self.hs.config.user_consent_version,
|
||||||
"url": "%s/_matrix/consent/public" % (self.hs.config.public_baseurl,),
|
"url": "%s/_matrix/consent?public=true" % (self.hs.config.public_baseurl,),
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class AuthRestServlet(RestServlet):
|
|||||||
|
|
||||||
html = TERMS_TEMPLATE % {
|
html = TERMS_TEMPLATE % {
|
||||||
'session': session,
|
'session': session,
|
||||||
'terms_url': "%s/_matrix/consent/public" % (
|
'terms_url': "%s/_matrix/consent?public=true" % (
|
||||||
self.hs.config.public_baseurl,
|
self.hs.config.public_baseurl,
|
||||||
),
|
),
|
||||||
'myurl': "%s/auth/%s/fallback/web" % (
|
'myurl': "%s/auth/%s/fallback/web" % (
|
||||||
@ -244,7 +244,7 @@ class AuthRestServlet(RestServlet):
|
|||||||
else:
|
else:
|
||||||
html = TERMS_TEMPLATE % {
|
html = TERMS_TEMPLATE % {
|
||||||
'session': session,
|
'session': session,
|
||||||
'terms_url': "%s/_matrix/consent/public" % (
|
'terms_url': "%s/_matrix/consent?public=true" % (
|
||||||
self.hs.config.public_baseurl,
|
self.hs.config.public_baseurl,
|
||||||
),
|
),
|
||||||
'myurl': "%s/auth/%s/fallback/web" % (
|
'myurl': "%s/auth/%s/fallback/web" % (
|
||||||
|
@ -30,7 +30,7 @@ from twisted.web.server import NOT_DONE_YET
|
|||||||
from synapse.api.errors import NotFoundError, StoreError, SynapseError
|
from synapse.api.errors import NotFoundError, StoreError, SynapseError
|
||||||
from synapse.config import ConfigError
|
from synapse.config import ConfigError
|
||||||
from synapse.http.server import finish_request, wrap_html_request_handler
|
from synapse.http.server import finish_request, wrap_html_request_handler
|
||||||
from synapse.http.servlet import parse_string
|
from synapse.http.servlet import parse_string, parse_boolean
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
# language to use for the templates. TODO: figure this out from Accept-Language
|
# language to use for the templates. TODO: figure this out from Accept-Language
|
||||||
@ -137,6 +137,13 @@ class ConsentResource(Resource):
|
|||||||
request (twisted.web.http.Request):
|
request (twisted.web.http.Request):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
public_version = parse_boolean(request, "public", default=False)
|
||||||
|
|
||||||
|
version = self._default_consent_version
|
||||||
|
username = None
|
||||||
|
userhmac = None
|
||||||
|
has_consented = False
|
||||||
|
if not public_version:
|
||||||
version = parse_string(request, "v",
|
version = parse_string(request, "v",
|
||||||
default=self._default_consent_version)
|
default=self._default_consent_version)
|
||||||
username = parse_string(request, "u", required=True)
|
username = parse_string(request, "u", required=True)
|
||||||
@ -152,12 +159,13 @@ class ConsentResource(Resource):
|
|||||||
u = yield self.store.get_user_by_id(qualified_user_id)
|
u = yield self.store.get_user_by_id(qualified_user_id)
|
||||||
if u is None:
|
if u is None:
|
||||||
raise NotFoundError("Unknown user")
|
raise NotFoundError("Unknown user")
|
||||||
|
has_consented = u["consent_version"] == version
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._render_template(
|
self._render_template(
|
||||||
request, "%s.html" % (version,),
|
request, "%s.html" % (version,),
|
||||||
user=username, userhmac=userhmac, version=version,
|
user=username, userhmac=userhmac, version=version,
|
||||||
has_consented=(u["consent_version"] == version),
|
has_consented=has_consented, public_version=public_version,
|
||||||
)
|
)
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
raise NotFoundError("Unknown policy version")
|
raise NotFoundError("Unknown policy version")
|
||||||
|
Loading…
Reference in New Issue
Block a user