Skip to content

Instantly share code, notes, and snippets.

@rgpublic
Created July 24, 2018 10:17
Show Gist options
  • Save rgpublic/8457d98b0fcc0c54893b9907f9b8b825 to your computer and use it in GitHub Desktop.
Save rgpublic/8457d98b0fcc0c54893b9907f9b8b825 to your computer and use it in GitHub Desktop.
Synapse deactive user
#!/bin/bash
echo -e "\e[97mPlease enter password for Synapse/Matrix root user:\e[0m";
read -s password
echo -e "\e[97mEnter user you'd like to deactivate\e[0m";
read user
url_user=`echo -n "$user" | jq -s -R -r @uri`
json=`curl -s --insecure -XPOST -d '{"type":"m.login.password", "user":"root", "password":"'$password'"}' "https://localhost:8448/_matrix/client/r0/login"`
access_token=`echo "$json" | jq -r ".access_token"`
curl --insecure -XPOST -H "Authorization: Bearer $access_token" -H "Content-Type: application/json" -d \
'{}' "https://localhost:8448/_matrix/client/r0/admin/deactivate/$url_user"
@catchra
Copy link

catchra commented Feb 19, 2022

@rgpublic
it doesn't look like you're script works anymore as it looks like the API endpoint has changed

from
https://localhost:8448/_matrix/client/r0/admin/deactivate/$url_user

to
https://localhost:8448/_synapse/admin/v1/deactivate/$url_user

other than that the script works well and it's very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment