-
-
Notifications
You must be signed in to change notification settings - Fork 678
Auto-generate username if none provided during registration #470
Auto-generate username if none provided during registration #470
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny things, and then of course converting the goroutine to just using a postgres sequence as was discussed out-of-band.
@@ -403,6 +406,18 @@ func Register( | |||
sessionID = util.RandomString(sessionIDLength) | |||
} | |||
|
|||
// Don't allow numeric username. But it's impractical to reserve numerics outside the range of int. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"numeric username" -> "numeric usernames"
Also do you mean by "it's impractical to reserve numerics outside the range of int"? Just that we don't need to worry about > MaxInt?
JSON: jsonerror.InvalidUsername("Numeric user IDs are reserved"), | ||
} | ||
} | ||
// auto generate a numeric username if r.Username is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"auto" -> "Auto"
b478f4b
to
1f668b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one typo. Tested and everything else looks good 👍
sessionID = util.RandomString(sessionIDLength) | ||
} | ||
|
||
// Don't allow numeric usernames less than MAX_INT64. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
greater than? :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ?
We are using numbers less than int_max 64, so only disallow numbers less than the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, for users trying to register a username. Thought this was referencing generated usernames.
if r.Username == "" { | ||
id, err := accountDB.GetNewNumericLocalpart(req.Context()) | ||
if err != nil { | ||
return jsonerror.InternalServerError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use return httputil.LogThenError(req, err)
so that it includes an appropriate error message in the response.
@APwhitehat Could you rebase on master please? |
aye aye edit: Sorry, I have a habit of rebasing instead of merge. :P |
b3ec18b
to
91587ee
Compare
Auto-generate username if none provided during registration.
Reserve numeric user IDs.
fixes #400.
Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>