server side validate nym

This commit is contained in:
keyan 2022-08-26 17:26:42 -05:00
parent d32fa05e42
commit 04d9c45156
1 changed files with 8 additions and 0 deletions

View File

@ -143,6 +143,14 @@ export default {
throw new AuthenticationError('you must be logged in') throw new AuthenticationError('you must be logged in')
} }
if (!/^[\w_]+$/.test(name)) {
throw new UserInputError('only letters, numbers, and _')
}
if (name.length > 32) {
throw new UserInputError('too long')
}
try { try {
await models.user.update({ where: { id: me.id }, data: { name } }) await models.user.update({ where: { id: me.id }, data: { name } })
} catch (error) { } catch (error) {