Skip to content

Change update user API to allow for crates.io username changes with some restrictions #13766

Description

@carols10cents

This issue feels somewhat large; this can be broken up into multiple PRs if desired.

This depends on the PR adding reserved crate names: #13765

This issue is only for the API changes; there is a separate issue for changes to the UI to make use of this new API ability.

In a similar manner as the deleted_crates table, add a deleted_usernames (or abandoned_usernames? because this will be for usernames that someone decided to stop using by changing to something else, not necessarily by deleting their account).

  • Add to update_user a field for username in the JSON

  • Similarly to the validate_crate_name function, create a validate_username function that:

    • Only allows usernames to contain alphanumeric characters ([a-zA-Z0-9]), hyphens (-), and underscores (_).
    • Doesn't allow usernames to start with a hyphen or underscore.
    • Doesn't allow usernames to exceed 39 characters.
    • Returns explanatory errors if any restrictions are violated.
  • Similarly to the check of deleted_crates in crate publishing, verify that:

    • The new username is available to use
    • The current user changing their name has not changed their name in the past 30 days
  • Similarly to the check of reserved_crate_names in crate publishing, verify that the new username isn't reserved

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions