Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As I was working on the new login page PR (#269), I realized that some of our input validation needs both a refactor and a policy lookover.
This PR implements some of the refactoring: renaming and juggling
badInputs
inCreateUserForm
andProfilePanel
to its ownvalidate
file insrc/lib
, and writing individual tests forisValidUsername
,isValidPassword
, andisValidDisplayname
functions. I'll probably also bundle any other input validation into this PR as well.From a policy perspective, just some things I noticed while writing tests
isValidUsername
should only accept things that can go in an email address before the@
. In particular, this means that @ should not be allowed in usernames, and + can. I think we should either change the policy to match something like gmail's email filter, or only allow alphanumeric characters.isValidPassword
is currently too restrictive. I think users should be allowed things like spaces, underscores, question marks and the like - and the length restriction (20 characters) is probably too small, especially if people use password managers. It's unlikely with our crowd, but withpassworks
in the works we should probably follow our own advice.isValidDisplayName
is probably also too restrictive: I don't see why many special characters should be allowed. we can also re-consider length when we redesign the profile panelAny thoughts? I think we made this policy stuff well over two years ago, and there might be some Firebase quirks I'm missing.
(also, you know what would be cool? If we didn't allow common passwords)
Note: this PR depends on #269.