Add missing auth commands to CLI
- auth register - POST /api/auth/register - auth forgot-password - POST /api/auth/forgot-password - auth reset-password - POST /api/auth/reset-password - auth account - PATCH /api/auth/account - auth users - GET /api/auth/users CLI now has 100% coverage of all API endpoints
This commit is contained in:
parent
2dea56ea39
commit
b354a0469d
@ -145,7 +145,13 @@ Displays text files in terminal, saves binary files to `/tmp/`.
|
||||
| Attach file | ✅ | ✅ | ✅ |
|
||||
| List projects | ✅ | ✅ | ❌ |
|
||||
| List sprints | ✅ | ✅ | ❌ |
|
||||
| Auth login/logout | ✅ | ✅ | ❌ |
|
||||
| Auth login | ✅ | ✅ | ❌ |
|
||||
| Auth logout | ✅ | ✅ | ❌ |
|
||||
| Auth register | ✅ | ✅ | ❌ |
|
||||
| Auth forgot-password | ✅ | ✅ | ❌ |
|
||||
| Auth reset-password | ✅ | ✅ | ❌ |
|
||||
| Auth account update | ✅ | ✅ | ❌ |
|
||||
| Auth list users | ✅ | ✅ | ❌ |
|
||||
| View attachments | ✅ | ❌ | ✅ |
|
||||
|
||||
### Auditing Coverage
|
||||
|
||||
@ -335,6 +335,69 @@ cmd_auth_session() {
|
||||
api_call GET "/auth/session"
|
||||
}
|
||||
|
||||
cmd_auth_register() {
|
||||
local email="$1"
|
||||
local password="$2"
|
||||
local name="${3:-}"
|
||||
|
||||
if [ -z "$email" ] || [ -z "$password" ]; then
|
||||
log_error "Usage: auth register <email> <password> [name]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Registering user..."
|
||||
local data
|
||||
data=$(jq -n --arg email "$email" --arg password "$password" --arg name "$name" \
|
||||
'{email: $email, password: $password, name: (if $name == "" then null else $name end)}')
|
||||
api_call POST "/auth/register" "$data"
|
||||
}
|
||||
|
||||
cmd_auth_forgot_password() {
|
||||
local email="$1"
|
||||
|
||||
if [ -z "$email" ]; then
|
||||
log_error "Usage: auth forgot-password <email>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Requesting password reset..."
|
||||
api_call POST "/auth/forgot-password" "{\"email\": \"$email\"}"
|
||||
}
|
||||
|
||||
cmd_auth_reset_password() {
|
||||
local token="$1"
|
||||
local password="$2"
|
||||
|
||||
if [ -z "$token" ] || [ -z "$password" ]; then
|
||||
log_error "Usage: auth reset-password <token> <new-password>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Resetting password..."
|
||||
api_call POST "/auth/reset-password" "{\"token\": \"$token\", \"password\": \"$password\"}"
|
||||
}
|
||||
|
||||
cmd_auth_account() {
|
||||
local field="$1"
|
||||
local value="$2"
|
||||
|
||||
if [ -z "$field" ] || [ -z "$value" ]; then
|
||||
log_error "Usage: auth account <field> <value>"
|
||||
echo "Fields: name, email"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Updating account $field..."
|
||||
local data
|
||||
data=$(jq -n --arg field "$field" --arg value "$value" '{($field): $value}')
|
||||
api_call PATCH "/auth/account" "$data"
|
||||
}
|
||||
|
||||
cmd_auth_users() {
|
||||
log_info "Fetching users..."
|
||||
api_call GET "/auth/users"
|
||||
}
|
||||
|
||||
#===================
|
||||
# DEBUG OPERATIONS
|
||||
#===================
|
||||
@ -379,6 +442,11 @@ AUTH COMMANDS:
|
||||
auth login <email> <pass> Log in
|
||||
auth logout Log out
|
||||
auth session Check current session
|
||||
auth register <email> <pass> Register new account
|
||||
auth forgot-password <email> Request password reset
|
||||
auth reset-password <tok> <pass> Reset password with token
|
||||
auth account <field> <value> Update account (name, email)
|
||||
auth users List all users
|
||||
|
||||
OTHER COMMANDS:
|
||||
debug Call debug endpoint
|
||||
@ -455,6 +523,11 @@ main() {
|
||||
login) cmd_auth_login "$@" ;;
|
||||
logout) cmd_auth_logout "$@" ;;
|
||||
session|whoami) cmd_auth_session "$@" ;;
|
||||
register|signup) cmd_auth_register "$@" ;;
|
||||
forgot-password|forgot) cmd_auth_forgot_password "$@" ;;
|
||||
reset-password|reset) cmd_auth_reset_password "$@" ;;
|
||||
account|profile) cmd_auth_account "$@" ;;
|
||||
users|list-users) cmd_auth_users "$@" ;;
|
||||
*) log_error "Unknown auth command: $subcmd"; show_help; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user