allow name checking if you aren't logged in

This commit is contained in:
keyan 2023-08-25 14:22:02 -05:00
parent a847b16b2c
commit 61c7bb28c2
1 changed files with 4 additions and 6 deletions

View File

@ -109,13 +109,11 @@ export default {
users: async (parent, args, { models }) => users: async (parent, args, { models }) =>
await models.user.findMany(), await models.user.findMany(),
nameAvailable: async (parent, { name }, { models, me }) => { nameAvailable: async (parent, { name }, { models, me }) => {
if (!me) { let user
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } }) if (me) {
user = await models.user.findUnique({ where: { id: me.id } })
} }
return user?.name?.toUpperCase() === name?.toUpperCase() || !(await models.user.findUnique({ where: { name } }))
const user = await models.user.findUnique({ where: { id: me.id } })
return user.name?.toUpperCase() === name?.toUpperCase() || !(await models.user.findUnique({ where: { name } }))
}, },
topCowboys: async (parent, { cursor }, { models, me }) => { topCowboys: async (parent, { cursor }, { models, me }) => {
const decodedCursor = decodeCursor(cursor) const decodedCursor = decodeCursor(cursor)