Skip to content

Check validity of username at signup #9

Open
@martinzlocha

Description

@martinzlocha
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

Activity

plietar

plietar commented on Jun 22, 2017

@plietar
Contributor

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

martinzlocha commented on Jun 22, 2017

@martinzlocha
MemberAuthor

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

jamesprinc3 commented on Jun 22, 2017

@jamesprinc3
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

levex commented on Jul 2, 2017

@levex
Member

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

added and removed on Jul 2, 2017
martinzlocha

martinzlocha commented on Jul 5, 2017

@martinzlocha
MemberAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @levex@jamesprinc3@plietar@martinzlocha

        Issue actions

          Check validity of username at signup · Issue #9 · docsocsf/mad