-
-
Save rgpublic/afdb4fc42804b15c644cef3bd172717a to your computer and use it in GitHub Desktop.
#!/bin/bash | |
SERVER="matrix.mycompany.com" | |
echo -e "\e[97mEnter user you'd like to deactivate\e[0m"; | |
read user | |
if [ "$user" == "" ]; then | |
echo "User required."; | |
exit; | |
fi | |
account="@$user:$SERVER"; | |
su postgres -c "psql synapse -c 'DELETE FROM users WHERE name='\''$account'\'';'" | |
su postgres -c "psql synapse -c 'DELETE FROM user_directory WHERE user_id='\''$account'\'';'" | |
su postgres -c "psql synapse -c 'DELETE FROM account_data WHERE user_id='\''$account'\'';'" | |
su postgres -c "psql synapse -c 'DELETE FROM profiles WHERE user_id='\''$user'\'';'" | |
su postgres -c "psql synapse -c 'DELETE FROM user_external_ids WHERE user_id='\''$account'\'';'" | |
@disconn3ct : If I check that table on our database it is empty. But, alas, we don't have any external users anyway. Probably that's why. So what exactly do you mean by "will give headaches"? Are you proposing that I add the following to my script?
su postgres -c "psql synapse -c 'DELETE FROM user_external_ids WHERE user_id='\''$user'\'';'"
Yes. Otherwise it still references the deleted user and when they attempt to log in again it says row not found
. (If future readers just want to prevent login from SSO, disable already does that.)
Thank you so much. I've changed it in the script. I cannot test it though. I don't know whether it should be the full account name ($account) or just the user name ($user). If you have any information on that, I'll be glad to know.
It is user_id, which afaik is always @USER:SYNAPSE
Thanks again, @disconn3ct . I've changed the script again accordingly.
There is an oidc mapping table also that will give headaches. If you miss
user_external_ids
you just get 'row not found' on login.