Last active
August 22, 2022 22:58
-
-
Save rachejazz/22cbc2eac3ae0671e901f5d5deaa4464 to your computer and use it in GitHub Desktop.
Shortcut user management automation: Shortcut (formerly Clubhouse) is a type of project management application. This script helps in deactivating users in bulk using their api. (For educational purpose only. Not recommended for production use)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### CREDS | |
email='user_email' | |
org_name='org' | |
echo 'from shortcut.com workspace web portal, go to inspect -> storage -> enter the following cookies' | |
echo 'Enter ajs_anonymous_id cookie: ' | |
read ajs_anonymous_id | |
echo 'Enter ajs_user_id' | |
read ajs_user_id | |
echo 'Enter amplitude_id_3c64fbb19dddbd7c2c4e00627785f644shortcut.com' | |
read amplitude_id | |
echo 'Enter __stripe_mid' | |
read stripe_mid | |
echo 'Enter sid' | |
read sid | |
cookies="Cookie: ajs_anonymous_id=$ajs_anonymous_id; ajs_user_id=$ajs_user_id; amplitude_id_3c64fbb19dddbd7c2c4e00627785f644shortcut.com=$amplitude_id; __stripe_mid=$stripe_mid; sid=$sid" | |
curl -s -H "Cookie: $cookies" \ | |
"https://app.shortcut.com/backend/api/private/user" > users | |
workspace=`cat users | jq -r --arg org $org_name '{"profiles"}|.[]|.[]|select (.organization2|.slug == $org)|.permissions|.[]|.organization|.id'` | |
organization=`cat users | jq -r --arg org $org_name '{"profiles"}|.[]|.[]|select (.organization2|.slug == $org)|.company|.id'` | |
echo "members extracted" && curl -s -H "Cookie: $cookies" \ | |
-H "Tenant-Organization2: $organization" \ | |
-H "Tenant-Workspace2: $workspace" \ | |
"https://app.shortcut.com/backend/api/private/owner/workspaces2/$workspace/members" > members | |
member_id=`cat members | jq -r --arg email $email '.[] | select (.profile|.email_address==$email) | .id'` | |
echo "disabling.." && curl -s -X PUT \ | |
-H "Cookie: $cookies" \ | |
-H "Tenant-Organization2: $organization" \ | |
-H "Tenant-Workspace2: $workspace"\ | |
"https://app.shortcut.com/backend/api/private/owner/workspaces2/$workspace/members/$member_id/disable" | |
rm users members |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment