allow name checking if you aren't logged in
This commit is contained in:
		
							parent
							
								
									a847b16b2c
								
							
						
					
					
						commit
						61c7bb28c2
					
				@ -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)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user