Skip to content

Commit

Permalink
pdsadmin/account: add reset-password
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob2161 committed Feb 22, 2024
1 parent a1b2e85 commit df799d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pdsadmin/account.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,35 @@ EOF
"https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateSubjectStatus" >/dev/null

echo "${DID} untaken down"
#
# account reset-password
#
elif [[ "${SUBCOMMAND}" == "reset-password" ]]; then
DID="${2:-}"
PASSWORD="$(openssl rand -base64 30 | tr -d "=+/" | cut -c1-24)"

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

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

curl_cmd_post \
--user "admin:${PDS_ADMIN_PASSWORD}" \
--data "{ \"did\": \"${DID}\", \"password\": \"${PASSWORD}\" }" \
"https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateAccountPassword" >/dev/null

echo
echo "Password reset for ${DID}"
echo "New password: ${PASSWORD}"
echo

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 @@ -27,6 +27,9 @@ account
untakedown <DID>
Remove a takedown an account specified by DID.
e.g. pdsadmin account takedown did:plc:xyz123abc456
password-reset <DID>
Reset a password for an account specified by DID.
e.g. pdsadmin account reset-password did:plc:xyz123abc456
request-crawl [<RELAY HOST>]
Request a crawl from a relay host.
Expand Down

0 comments on commit df799d1

Please sign in to comment.