- fixed webfinger test to work with docker(hackfix)

- fixed permissions middleware to properly authenticate users
This commit is contained in:
Ulf Gebhardt 2021-01-22 16:53:13 +01:00
parent 9ecdfdab44
commit 4b04a6bb5c
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
2 changed files with 15 additions and 5 deletions

View File

@ -98,12 +98,12 @@ describe('webfinger', () => {
expect(json).toHaveBeenCalledWith({
links: [
{
href: 'http://localhost:3000/activitypub/users/some-user',
href: 'http://webapp:3000/activitypub/users/some-user',
rel: 'self',
type: 'application/activity+json',
},
],
subject: 'acct:some-user@localhost:3000',
subject: 'acct:some-user@webapp:3000',
})
})
})

View File

@ -29,15 +29,25 @@ const onlyYourself = rule({
const isMyOwn = rule({
cache: 'no_cache',
})(async (parent, args, context, info) => {
return context.user.id === parent.id
})(async (parent, args, { user }, info) => {
return user && user.id === parent.id
})
const isMySocialMedia = rule({
cache: 'no_cache',
})(async (_, args, { user }) => {
// We need a User
if (!user){
return false
}
let socialMedia = await neode.find('SocialMedia', args.id)
socialMedia = await socialMedia.toJson()
// Did we find a social media node?
if(!socialMedia){
return false
}
socialMedia = await socialMedia.toJson() // whats this for?
//Is it my social media entry?
return socialMedia.ownedBy.node.id === user.id
})