Add alpha numeric regex to username on sign up

resolves #82
This commit is contained in:
Kurt Hutten
2020-11-10 20:49:19 +11:00
parent 14716d1fb0
commit 01f1a02837
4 changed files with 8 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import { createUserInsecure } from 'src/services/users/users.js'
import { db } from 'src/lib/db'
import { enforceAlphaNumeric } from 'src/services/helpers'
export const handler = async (req, _context) => {
const body = JSON.parse(req.body)
@@ -74,7 +75,7 @@ export const handler = async (req, _context) => {
const newSeed = count === 1 ? `${seed}_${count}` : seed.slice(0,-1) + count
return generateUniqueUserName(newSeed, count)
}
const userNameSeed = email.split('@')[0]
const userNameSeed = enforceAlphaNumeric(email.split('@')[0])
const userName = await generateUniqueUserName(userNameSeed) // TODO maybe come up with a better default userName?
const input = {
email,