Skip to content

Add unlock-user command to unlock user accounts#306

Open
duanemay wants to merge 1 commit into
masterfrom
Add-unlock-user
Open

Add unlock-user command to unlock user accounts#306
duanemay wants to merge 1 commit into
masterfrom
Add-unlock-user

Conversation

@duanemay

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 22:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new uaa unlock-user CLI command (plus docs) to unlock user accounts by username, complementing existing user-management commands (activate/deactivate/delete/etc.).

Changes:

  • Introduces unlock-user command implementation that PATCHes /Users/{id}/status with {"locked": false}.
  • Adds Ginkgo/Gomega integration tests covering success paths, flags (--verbose, --origin, --zone), and error/validation cases.
  • Updates command reference docs to include the new command and its dedicated page.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
docs/commands/unlock-user.md Adds documentation for the new unlock-user command (usage, flags, examples).
docs/commands.md Adds unlock-user to the “Managing Users” command index.
cmd/unlock_user.go Implements the unlock-user cobra command and the PATCH call to unlock a user.
cmd/unlock_user_test.go Adds integration tests for unlock-user behavior and validations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/unlock_user.go
Comment on lines +23 to +40
err = unlockUserByID(api, user.ID, zoneID)
if err != nil {
return err
}

log.Infof("Account for user %v successfully unlocked.", utils.Emphasize(user.Username))
return nil
}

// unlockUserByID makes a PATCH request to /Users/{id}/status with {"locked": false}
func unlockUserByID(api *uaa.API, userID, zoneID string) error {
path := fmt.Sprintf("/Users/%s/status", userID)
data := `{"locked": false}`

headers := []string{"Content-Type: application/json"}
if zoneID != "" {
headers = append(headers, fmt.Sprintf("X-Identity-Zone-Id: %s", zoneID))
}
Comment thread cmd/unlock_user.go
Comment on lines +42 to +49
_, _, status, err := api.Curl(path, "PATCH", data, headers)
if err != nil {
return err
}

if status >= 400 {
return fmt.Errorf("unlock user failed with status %d", status)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants