mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-08 07:34:55 -04:00
Return m.change_password.enabled=false if local database is disabled (#9588)
Instead of if the user does not have a password hash. This allows a SSO user to add a password to their account, but only if the local password database is configured.
This commit is contained in:
parent
e3bc0e6f7c
commit
8000cf1315
4 changed files with 58 additions and 15 deletions
|
@ -13,12 +13,18 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Tuple
|
||||
|
||||
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
|
||||
from synapse.http.servlet import RestServlet
|
||||
from synapse.http.site import SynapseRequest
|
||||
from synapse.types import JsonDict
|
||||
|
||||
from ._base import client_patterns
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from synapse.server import HomeServer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -27,21 +33,16 @@ class CapabilitiesRestServlet(RestServlet):
|
|||
|
||||
PATTERNS = client_patterns("/capabilities$")
|
||||
|
||||
def __init__(self, hs):
|
||||
"""
|
||||
Args:
|
||||
hs (synapse.server.HomeServer): server
|
||||
"""
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
super().__init__()
|
||||
self.hs = hs
|
||||
self.config = hs.config
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastore()
|
||||
self.auth_handler = hs.get_auth_handler()
|
||||
|
||||
async def on_GET(self, request):
|
||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
user = await self.store.get_user_by_id(requester.user.to_string())
|
||||
change_password = bool(user["password_hash"])
|
||||
async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
|
||||
await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
change_password = self.auth_handler.can_change_password()
|
||||
|
||||
response = {
|
||||
"capabilities": {
|
||||
|
@ -58,5 +59,5 @@ class CapabilitiesRestServlet(RestServlet):
|
|||
return 200, response
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
def register_servlets(hs: "HomeServer", http_server):
|
||||
CapabilitiesRestServlet(hs).register(http_server)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue