Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check validity of username at signup #9

Open
martinzlocha opened this issue Jun 22, 2017 · 5 comments
Open

Check validity of username at signup #9

martinzlocha opened this issue Jun 22, 2017 · 5 comments

Comments

@martinzlocha
Copy link
Member

Detailed Description

When a student is signing up the form should check whether the provided username is valid.

Context

This change will reduce the number of usernames submitted which contain typo's. It will also verify that the username provided isn't an arbitrary string.

Possible Implementation

Validating of user input into forms is done within forms.py. Usage of RegEx is preferred over manual string parsing. If an invalid username is provided then the form should raise a ValidationError.

Example of valid usernames:

  • mz4315
  • abc13
  • xy12315
  • ab117

Example of invalid usernames:

  • a1216
  • abcf16
  • a1b17
  • ab1210
@plietar
Copy link
Contributor

plietar commented Jun 22, 2017

Why is ab1210 a bad username ?

In general I don't see a point in checking usernames against a pattern. You'll need to check them against the real database eventually

@martinzlocha
Copy link
Member Author

I considered it bad because the student arrived to Imperial in 2010 therefore isnt a UG student probably.

The issue is that TeachDB is updated very late (late September) and I'm not sure when are other databases updated and if we have access to them. Given that we want to allocate the students ASAP it will be too late.

@jamesprinc3
Copy link
Collaborator

I considered it bad because the student arrived to Imperial in 2010 therefore isnt a UG student probably.

I don't think we should be inferring this much at a regex stage. Probably better to just check that there are some numbers and there are some letters, and they are below some sensible limit.

@levex
Copy link
Member

levex commented Jul 2, 2017

Possible regexp candidate: ^[A-z]{2,3}\d+$

@levex levex added easy and removed medium labels Jul 2, 2017
@martinzlocha
Copy link
Member Author

martinzlocha commented Jul 5, 2017

Even better ^([A-z]{2}\d{3,5}|[A-z]{3}\d{2})$ if you want to be more specific.

Edit: This won't actually work for everyone, use ^[A-z]{2,3}\d{2,5}$ instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants