mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
v-change-wordpress-admin-passwords: enhance admin reassignment logic to handle default user selection
This commit is contained in:
parent
bf54a85a51
commit
cdf10aede1
1 changed files with 9 additions and 1 deletions
|
@ -59,9 +59,14 @@ ADMIN_LIST_CSV=$(eval "$RUN")
|
|||
|
||||
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
|
||||
|
||||
DEFAULT_USER=""
|
||||
|
||||
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
|
||||
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
|
||||
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
|
||||
if [ "$PID" = "1" ]; then
|
||||
DEFAULT_USER="$PLOGIN"
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
|
@ -84,11 +89,14 @@ while IFS=',' read -r ID LOGIN EMAIL; do
|
|||
echo "Cannot delete the only administrator account."
|
||||
break
|
||||
fi
|
||||
DEFAULT_USER="${OTHER_USERS[0]}"
|
||||
if [ "$DEFAULT_USER" = "" ]; then
|
||||
DEFAULT_USER="${OTHER_USERS[0]}"
|
||||
fi
|
||||
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
|
||||
while true; do
|
||||
read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
|
||||
REASSIGN=${REASSIGN:-$DEFAULT_USER}
|
||||
DEFAULT_USER=$REASSIGN
|
||||
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
|
||||
break
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue