Riot

From Hackepedia
Jump to navigationJump to search

Change a user's a password

$ ssh -L 8448:localhost:8448 serveruser@matrix.server.com
$ curl -XPOST -d '{"type":"m.login.password", "user":"<userId>", "password":"<pasword>"}' "https://localhost:8448/_matrix/client/r0/login"

get token

$ curl -XPOST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"new_password":"<new_password>"}' "https://localhost:8448/_matrix/client/r0/admin/reset_password/<userId>"

Deactivate a user

#!/bin/bash 
# from [gist]
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"