diff --git a/pdsadmin/account.sh b/pdsadmin/account.sh index 86a5f1e..5ed5e69 100644 --- a/pdsadmin/account.sh +++ b/pdsadmin/account.sh @@ -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} " >/dev/stderr + exit 1 + fi + + if [[ "${HANDLE}" == "" ]]; then + echo "ERROR: missing handle parameter" >/dev/stderr + echo "Usage: $0 ${SUBCOMMAND} " + exit 1 + fi + + if [[ "${DID}" != did:* ]]; then + echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr + echo "Usage: $0 ${SUBCOMMAND} " >/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 diff --git a/pdsadmin/help.sh b/pdsadmin/help.sh index 1a0b16e..3a0eb69 100644 --- a/pdsadmin/help.sh +++ b/pdsadmin/help.sh @@ -30,6 +30,9 @@ account reset-password Reset a password for an account specified by DID. e.g. pdsadmin account reset-password did:plc:xyz123abc456 + change-handle + Change the handle for an account specified by DID + e.g. pdsadmin account change-handle did:plc:xyz123abc456 alice.example.com request-crawl [] Request a crawl from a relay host.