Improve username generation

This commit is contained in:
Tanner Collin 2021-11-28 05:09:14 +00:00
parent 70764ee53e
commit 822cb9ec5c

View File

@ -81,14 +81,13 @@ export function SignupForm(props) {
const genUsername = () => { const genUsername = () => {
if (input.first_name && input.last_name) { if (input.first_name && input.last_name) {
let first_name = input.first_name.trim(); let first_name = input.first_name.trim().toLowerCase();
let last_name = input.last_name.trim(); let last_name = input.last_name.trim().toLowerCase();
first_name = first_name.replace(/[^a-z- ]+/g, ''); first_name = first_name.replace(/[^a-z- ]+/g, '');
last_name = last_name.replace(/[^a-z- ]+/g, ''); last_name = last_name.replace(/[^a-z- ]+/g, '');
first_name = first_name.replace(/[ -]/g, '.'); first_name = first_name.replace(/[ -]/g, '.');
last_name = last_name.replace(/[ -]/g, '.'); last_name = last_name.replace(/[ -]/g, '.');
const username = first_name + '.' + last_name; return first_name + '.' + last_name;
return username.toLowerCase();
} else { } else {
return ''; return '';
} }