Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add account change-handle to pdsadmin #116

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions pdsadmin/account.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,41 @@ elif [[ "${SUBCOMMAND}" == "reset-password" ]]; then
echo "New password: ${PASSWORD}"
echo

#
# account change-handle
#
elif [[ "${SUBCOMMAND}" == "change-handle" ]]; then
DID="${2:-}"
HANDLE="${3:-}"

if [[ "${DID}" == "" ]]; then
echo "ERROR: missing DID parameter." >/dev/stderr
echo "Usage: $0 ${SUBCOMMAND} <DID> <HANDLE>" >/dev/stderr
exit 1
fi

if [[ "${HANDLE}" == "" ]]; then
echo "ERROR: missing handle parameter" >/dev/stderr
echo "Usage: $0 ${SUBCOMMAND} <DID> <HANDLE>"
exit 1
fi

if [[ "${DID}" != did:* ]]; then
echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr
echo "Usage: $0 ${SUBCOMMAND} <DID> <HANDLE>" >/dev/stderr
exit 1
fi

RESULT="$(curl_cmd_post_nofail \
--user "admin:${PDS_ADMIN_PASSWORD}" \
--data "{\"did\":\"${DID}\",\"handle\":\"${HANDLE}\"}" \
"https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateAccountHandle")"

if [[ -n "$(echo "$RESULT" | jq --raw-output '.error')" ]]; then
echo "ERROR: $(echo "$RESULT" | jq --raw-output '.message')" >/dev/stderr
exit 1
fi

else
echo "Unknown subcommand: ${SUBCOMMAND}" >/dev/stderr
exit 1
Expand Down
3 changes: 3 additions & 0 deletions pdsadmin/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ account
reset-password <DID>
Reset a password for an account specified by DID.
e.g. pdsadmin account reset-password did:plc:xyz123abc456
change-handle <DID> <HANDLE>
Change the handle for an account specified by DID
e.g. pdsadmin account change-handle did:plc:xyz123abc456 alice.example.com

request-crawl [<RELAY HOST>]
Request a crawl from a relay host.
Expand Down