@orbiting/backend-modules-auth
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,6 +0,23 @@ | ||
<a name="2.0.0"></a> | ||
# 2.0.0 (2017-12-20) | ||
<a name="2.1.0"></a> | ||
# 2.1.0 (2017-12-21) | ||
<a name="2.1.0"></a> | ||
# 2.1.0 (2017-12-21) | ||
### Bug Fixes | ||
* **backend-modules-auth:** fix and or logic ([55e316e](https://github.com/orbiting/backend-modules/commit/55e316e)) | ||
* **backend-modules-auth:** only allow editors to access user.email ([ea04821](https://github.com/orbiting/backend-modules/commit/ea04821)) | ||
### Features | ||
* **backend-modules-auth:** allow admins and supporters to access get user details ([6dd1017](https://github.com/orbiting/backend-modules/commit/6dd1017)) | ||
* **backend-modules-auth:** expose user createdAt and updatedAt ([f5d3608](https://github.com/orbiting/backend-modules/commit/f5d3608)) | ||
<a name="2.0.0"></a> | ||
@@ -7,0 +24,0 @@ # 2.0.0 (2017-12-20) |
@@ -16,9 +16,8 @@ const transformUser = require('../../../lib/transformUser') | ||
if ( | ||
!user || | ||
(!user.hasPublicProfile && !Roles.userIsMe(user, me)) | ||
user && | ||
(user.hasPublicProfile || Roles.userIsMeOrInRoles(user, me, ['admin', 'supporter'])) | ||
) { | ||
return null | ||
return transformUser(user) | ||
} | ||
return transformUser(user) | ||
return null | ||
} |
const Roles = require('../../lib/Roles') | ||
const userAccessRoles = ['admin', 'supporter'] | ||
module.exports = { | ||
email (user, args, { pgdb, user: me }) { | ||
if (Roles.userIsMeOrInRoles(user, me, ['admin', 'supporter', 'accountant', 'editor'])) { | ||
if (Roles.userIsMeOrInRoles(user, me, [...userAccessRoles, 'editor'])) { | ||
return user.email | ||
@@ -23,3 +24,11 @@ } | ||
return [] | ||
}, | ||
createdAt (user, args, { user: me }) { | ||
Roles.ensureUserIsMeOrInRoles(user, me, userAccessRoles) | ||
return user._raw.createdAt | ||
}, | ||
updatedAt (user, args, { user: me }) { | ||
Roles.ensureUserIsMeOrInRoles(user, me, userAccessRoles) | ||
return user._raw.updatedAt | ||
} | ||
} |
@@ -12,2 +12,4 @@ module.exports = ` | ||
roles: [String!]! | ||
createdAt: DateTime! | ||
updatedAt: DateTime! | ||
} | ||
@@ -14,0 +16,0 @@ |
@@ -90,2 +90,7 @@ const t = require('./t') | ||
const ensureUserIsMeOrInRoles = (user, me, roles) => ( | ||
userIsMe(user, me) || | ||
ensureUserIsInRoles(me, roles) | ||
) | ||
const userIsMeOrHasProfile = (user, me) => ( | ||
@@ -103,2 +108,3 @@ user._raw.hasPublicProfile || | ||
userIsMeOrInRoles, | ||
ensureUserIsMeOrInRoles, | ||
userIsMeOrHasProfile, | ||
@@ -105,0 +111,0 @@ ensureUserIsInRoles, |
{ | ||
"name": "@orbiting/backend-modules-auth", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "auth migrations, seeds, middleware, graphql schema and resolvers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41495
1001