Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

user createdAt, updatedAt #7

Merged
merged 4 commits into from
Dec 21, 2017
Merged

user createdAt, updatedAt #7

merged 4 commits into from
Dec 21, 2017

Conversation

patte
Copy link
Contributor

@patte patte commented Dec 20, 2017

No description provided.

… user details

affects: @orbiting/backend-modules-auth
@patte patte changed the title wip: admin user createdAt, updatedAt Dec 21, 2017
@patte patte requested a review from tpreusse December 21, 2017 09:30
!user ||
(!user.hasPublicProfile && !Roles.userIsMe(user, me))
user &&
user.hasPublicProfile || Roles.userIsMeOrInRoles(user, me, ['admin', 'supporter'])
Copy link
Contributor

@tpreusse tpreusse Dec 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap this line in parenthesis:

> undefined && undefiend.hasPublicProfile || true
true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely

@@ -1,8 +1,9 @@
const Roles = require('../../lib/Roles')
const userAccessRoles = ['admin', 'supporter', 'editor']
Copy link
Contributor

@tpreusse tpreusse Dec 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO editor should not be a general user access role—just email

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree and changed

@@ -20,5 +21,13 @@ module.exports = {
return user.roles
}
return []
},
createdAt (user, args, { user: me }) {
Roles.ensureUserIsMeOrInRoles(user, me, userAccessRoles)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it's unclear when we should throw based on field level access control. Who will consume createdAt and updatedAt? I can see use cases in the public profile for createdAt. Maybe just make it nullable and return null when not authorised?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disagree. IMHO the schema should represent reality. Every user has a createdAt and an updatedAt date. I think we should continue to treat access violations with throwing an exception. The client is responsible to only request the appropriate fields, in this case it's the admin tool.

affects: @orbiting/backend-modules-auth
@patte patte merged commit e80d43a into master Dec 21, 2017
@patte patte deleted the admin branch December 21, 2017 12:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants