Phone Login Admin Operations — Exact Lookup, Profile Updates, and Controlled Deletion
Short answer: model every admin action as a validated, auditable, recoverable state transition; use the user ID after lookup, and put deletion behind an explicit policy check. This is the constraint that changes the design. A media app adding phone one-time-code login still needs an admin console that can find the right account, correct a profile, or remove access without turning an email typo…
The article argues that admin actions should be designed as distinct, auditable, and reversible state transitions. When adding phone one-time-code login, the console must be able to find, update, and delete accounts without irreversible mistakes from typos.
The recommended approach is to keep lookup, update, and delete as separate commands with their own authorization checks and audit records. This allows for clear evaluation of each operation separately. The example given is from a media app that implements lookup, update, and delete as separate commands with authorization and audit records.
The author tested a simple implementation that combined email lookup, profile update, and deletion into one generic handler. However, this approach led to problems like email address changes and retries causing multiple state changes. The author's solution involves recording transitions like "active - deletion_pending - deleted", including actor, reason, request ID, and snapshot.
The key steps are:
1. Lookup to get an immutable user ID
2. Validate allowed update fields
3. Require fresh privilege check and confirmation token for deletion
4. Provide a restore job using snapshots if retention policy allows
The article emphasizes verifying authorization, recording transitions, and enabling recovery. Measures to consider include authorization-denied rates, email search accuracy, revocation times, and restore frequencies. Proper separation of policy and mutable identifiers is crucial. Email is good for lookup, but the user ID is the stable key for all other operations.
The client code demonstrates exact email lookup followed by profile patching with bearer authentication and retry handling. It logs request IDs for deduplication. The example queries an infra service using documented paths.
Ultimately, the design should focus on where policy and recovery live rather than a feature checklist. The same acceptance tests should be run against different managed auth products to evaluate audit events and context provided. Managed products tend to offer more out-of-the-box capabilities.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.