mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Fix #2294
Ideally we would not have this inconsistent edge case that we filter
through the user type. Much better would be a graphql query like:
```graphql
{
User(filter: { primary_email: { email: "something@example.org" } }) {
id
name
slug
}
}
```
This commit is contained in:
parent
c3d8cb68e0
commit
b0d20ede71
@ -100,7 +100,7 @@ const noEmailFilter = rule({
|
||||
const publicRegistration = rule()(() => !!CONFIG.PUBLIC_REGISTRATION)
|
||||
|
||||
// Permissions
|
||||
const permissions = shield(
|
||||
export default shield(
|
||||
{
|
||||
Query: {
|
||||
'*': deny,
|
||||
@ -176,5 +176,3 @@ const permissions = shield(
|
||||
fallbackRule: allow,
|
||||
},
|
||||
)
|
||||
|
||||
export default permissions
|
||||
|
||||
@ -49,10 +49,22 @@ export default {
|
||||
User: async (object, args, context, resolveInfo) => {
|
||||
const { email } = args
|
||||
if (email) {
|
||||
const e = await instance.first('EmailAddress', { email })
|
||||
let user = e.get('belongsTo')
|
||||
user = await user.toJson()
|
||||
return [user.node]
|
||||
let session
|
||||
try {
|
||||
session = context.driver.session()
|
||||
const readTxResult = await session.readTransaction(txc => {
|
||||
const result = txc.run(
|
||||
`
|
||||
MATCH (user:User)-[:PRIMARY_EMAIL]->(e:EmailAddress {email: $args.email})
|
||||
RETURN user`,
|
||||
{ args },
|
||||
)
|
||||
return result
|
||||
})
|
||||
return readTxResult.records.map(r => r.get('user').properties)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
return neo4jgraphql(object, args, context, resolveInfo)
|
||||
},
|
||||
|
||||
@ -70,6 +70,21 @@ describe('User', () => {
|
||||
data: { User: [{ name: 'Johnny' }] },
|
||||
})
|
||||
})
|
||||
|
||||
it('non-existing email address, issue #2294', async () => {
|
||||
// see: https://github.com/Human-Connection/Human-Connection/issues/2294
|
||||
await expect(
|
||||
query({
|
||||
query: userQuery,
|
||||
variables: {
|
||||
email: 'this-email-does-not-exist@example.org',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
data: { User: [] },
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user