Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Registration: Allow registration without a username #400

Closed
3 tasks
anoadragon453 opened this issue Mar 2, 2018 · 3 comments · Fixed by #470
Closed
3 tasks

Registration: Allow registration without a username #400

anoadragon453 opened this issue Mar 2, 2018 · 3 comments · Fixed by #470

Comments

@anoadragon453
Copy link
Member

anoadragon453 commented Mar 2, 2018

Spec URL: https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-register

If omitted, the homeserver MUST generate a Matrix ID local part.

Phase: 1

We currently do not generate a username if username is not set as part of a POST request to /register.

Sent Request

{
    "password": "asd",
    "auth": {
        "type": "m.login.dummy",
        "session": "Mxa1dMHgfP2VTIFNNgSkDL5n"
    }
}

Received Response

Synapse:

{
  "access_token": "...",
  "home_server": "amorgan.xyz",
  "user_id": "@15:amorgan.xyz",
  "device_id": "IGKRGSXVFW"
}

Dendrite:

{
  "errcode": "M_INVALID_USERNAME",
  "error": "User ID can only contain characters a-z, 0-9, or '_-./'"
}

I believe Synapse will just set the new username to the next available user ID. So for instance, if my homeserver has registered 3 users, the newly generated username would be @4:homeserver.xyz. We can either use this method or some other method that generates ID in an increasing manner.

Summary:

  • Don't error out if a username is not provided as part of registration
  • Generate and return a new username if one was not provided
  • Create test case(s) that checks for a successful registration without a username, and that the returned generated username is valid
@jsinghrai
Copy link

Mind If I take this issue.

@anoadragon453
Copy link
Member Author

@jsinghrai Go for it!

@anoadragon453
Copy link
Member Author

anoadragon453 commented Mar 2, 2018

We currently validate usernames here:

// Squash username to all lowercase letters
r.Username = strings.ToLower(r.Username)
if resErr = validateUserName(r.Username); resErr != nil {
return *resErr
}

If there is no username, then we should generate one instead and use that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants