forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_user.sh
More file actions
executable file
·34 lines (28 loc) · 1.05 KB
/
delete_user.sh
File metadata and controls
executable file
·34 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -e
unset CDPATH
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
eval $(grep 'export OVERRIDE_AUTH_SECRET=' dev/launch.sh)
username_to_delete="$1"
user_id_to_delete=$(
curl -sS \
-H "X-Override-Auth-Secret: $OVERRIDE_AUTH_SECRET" \
-H 'X-Override-Auth-Username: dev' \
-H 'Content-Type: application/json; charset=utf-8' \
-XPOST \
-d '{"query":"query($username: String!) { user(username: $username) { id } }","variables":{"username":"'"$username_to_delete"'"}}' \
http://localhost:3080/.api/graphql \
| jq -c -r '.data.user.id'
)
if [ "$user_id_to_delete" = "null" ]; then
echo User not found: $username_to_delete
exit 1
fi
curl -sS \
-H "X-Override-Auth-Secret: $OVERRIDE_AUTH_SECRET" \
-H 'X-Override-Auth-Username: dev' \
-H 'Content-Type: application/json; charset=utf-8' \
-XPOST \
-d '{"query":"mutation($user: ID!) { deleteUser(user: $user) { alwaysNil } }","variables":{"user":"'"$user_id_to_delete"'"}}' \
http://localhost:3080/.api/graphql
echo