I’ll show you an example of changing a regular user’s rights to administrator and owner, as well as adding additional rights for the API.
First, let’s open the shell:
su zulip
cd /home/zulip/deployments/current
./manage.py shell
To make a regular user an administrator, run all the commands below:
from zerver.models import UserProfile
user = UserProfile.objects.get(email="[email protected]")
user.is_admin = True
user.save()
print(f"User {user.email} now administrator.")
To give this user maximum owner rights, run these commands as well:
user.is_realm_owner = True
user.save()
Done, let’s exit the shell:
exit()
Once, I needed to migrate the API from Discord to Zulip. The bot or user using the API key needed to be given additional permissions:
sudo -u zulip /home/zulip/deployments/current/manage.py shell
from zerver.models import UserProfile
user = UserProfile.objects.get(email='[email protected]')
user.can_create_users = True
user.can_forge_sender = True
user.save()
Let’s check the rights:
print(user.can_create_users)
print(user.can_forge_sender)
exit()
See also my article:
Installing Zulip