Merge pull request 'fix: fix: hire-an-agent must use Forgejo CLI for password reset — API PATCH ignores must_change_password (#206)' (#207) from fix/issue-206 into main
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
This commit is contained in:
commit
999212b1cd
1 changed files with 15 additions and 15 deletions
30
bin/disinto
30
bin/disinto
|
|
@ -28,6 +28,16 @@ source "${FACTORY_ROOT}/lib/env.sh"
|
||||||
|
|
||||||
# ── Helpers ──────────────────────────────────────────────────────────────────
|
# ── Helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
# Execute a command in the Forgejo container (for admin operations)
|
||||||
|
_forgejo_exec() {
|
||||||
|
local use_bare="${DISINTO_BARE:-false}"
|
||||||
|
if [ "$use_bare" = true ]; then
|
||||||
|
docker exec -u git disinto-forgejo "$@"
|
||||||
|
else
|
||||||
|
docker compose -f "${FACTORY_ROOT}/docker-compose.yml" exec -T -u git forgejo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
disinto — autonomous code factory CLI
|
disinto — autonomous code factory CLI
|
||||||
|
|
@ -569,15 +579,6 @@ setup_forge() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "── Forge setup ────────────────────────────────────────"
|
echo "── Forge setup ────────────────────────────────────────"
|
||||||
|
|
||||||
# Helper: run a command inside the Forgejo container
|
|
||||||
_forgejo_exec() {
|
|
||||||
if [ "$use_bare" = true ]; then
|
|
||||||
docker exec -u git disinto-forgejo "$@"
|
|
||||||
else
|
|
||||||
docker compose -f "${FACTORY_ROOT}/docker-compose.yml" exec -T -u git forgejo "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if Forgejo is already running
|
# Check if Forgejo is already running
|
||||||
if curl -sf --max-time 5 "${forge_url}/api/v1/version" >/dev/null 2>&1; then
|
if curl -sf --max-time 5 "${forge_url}/api/v1/version" >/dev/null 2>&1; then
|
||||||
echo "Forgejo: ${forge_url} (already running)"
|
echo "Forgejo: ${forge_url} (already running)"
|
||||||
|
|
@ -2672,12 +2673,11 @@ disinto_hire_an_agent() {
|
||||||
echo " User '${agent_name}' already exists"
|
echo " User '${agent_name}' already exists"
|
||||||
# Reset user password so we can get a token (#184)
|
# Reset user password so we can get a token (#184)
|
||||||
user_pass="agent-$(head -c 16 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | head -c 20)"
|
user_pass="agent-$(head -c 16 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | head -c 20)"
|
||||||
# Reset password using basic auth (admin token fallback would poison subsequent calls)
|
# Use Forgejo CLI to reset password (API PATCH ignores must_change_password in Forgejo 11.x)
|
||||||
if curl -sf -X PATCH \
|
if _forgejo_exec forgejo admin user change-password \
|
||||||
-u "${admin_user}:${admin_pass}" \
|
--username "${agent_name}" \
|
||||||
-H "Content-Type: application/json" \
|
--password "${user_pass}" \
|
||||||
"${forge_url}/api/v1/admin/users/${agent_name}" \
|
--must-change-password=false >/dev/null 2>&1; then
|
||||||
-d "{\"password\":\"${user_pass}\",\"must_change_password\":false}" >/dev/null 2>&1; then
|
|
||||||
echo " Reset password for existing user '${agent_name}'"
|
echo " Reset password for existing user '${agent_name}'"
|
||||||
else
|
else
|
||||||
echo " Warning: could not reset password for existing user" >&2
|
echo " Warning: could not reset password for existing user" >&2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue