Opinionated SaaS quick-start with pre-built user account and organization system for full-stack application development in React, Node.js, GraphQL and PostgreSQL. Powered by PostGraphile, TypeScript, Apollo Client, Graphile Worker, Graphile Migrate, GraphQL Code Generator, Ant Design and Next.js
Usernames automatically generated from short first names, e.g "A B" cause an error, the check fails (i.e. it doesn't match '^[a-zA-Z]([a-zA-Z0-9][_]?)+$').
Steps to reproduce
Run a link_or_register_user with the name "A B".
Expected results
A username like "A_B", or at worst, "user1"
Actual results
Exception: new row for relation "users" violates check constraint "users_username_check"
Additional context
None seems relevant.
Possible Solution
Possible Chesterton's fence notwithstanding, the regexp for username checks could be changed from
^[a-zA-Z]([a-zA-Z0-9][_]?)+$
to
^[a-zA-Z]([a-zA-Z0-9_]?)+$
This has the unfortunate side effect of allowing multiple underscores in a row, but I don't think that's more important than allowing short first names.
The underscore should be at the front of the parens not at the end; I did not intend to allow trailing underscore, and I did intend to allow A_B. I.e. the regexp should be: '^[a-zA-Z]([_]?[a-zA-Z0-9])+$'
Summary
Usernames automatically generated from short first names, e.g "A B" cause an error, the check fails (i.e. it doesn't match
'^[a-zA-Z]([a-zA-Z0-9][_]?)+$'
).Steps to reproduce
Run a link_or_register_user with the name "A B".
Expected results
A username like "A_B", or at worst, "user1"
Actual results
Exception: new row for relation "users" violates check constraint "users_username_check"
Additional context
None seems relevant.
Possible Solution
Possible Chesterton's fence notwithstanding, the regexp for username checks could be changed from
^[a-zA-Z]([a-zA-Z0-9][_]?)+$
to
^[a-zA-Z]([a-zA-Z0-9_]?)+$
This has the unfortunate side effect of allowing multiple underscores in a row, but I don't think that's more important than allowing short first names.