Skip to content

Commit

Permalink
fix: make getCurrentUser and getCurrentUserGroups instance methods again
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kirkpatrick committed May 30, 2017
1 parent a187050 commit 495b017
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
'extends': 'fullcube',
'root': true,
'rules': {
no-console: 0
extends: fullcube,
root: true,
rules: {
no-console: 0,
class-methods-use-this: 0
}
}
10 changes: 5 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = class AccessUtils {
if (typeof Model.observe === 'function') {
debug('Attaching access observer to %s', modelName)
Model.observe('access', (ctx, next) => {
const currentUser = AccessUtils.getCurrentUser()
const currentUser = this.getCurrentUser()

if (currentUser) {
// Do not filter if options.skipAccess has been set.
Expand Down Expand Up @@ -198,8 +198,8 @@ module.exports = class AccessUtils {
getUserGroups(userId, force, cb) {
force = force || false
cb = cb || createPromiseCallback()
const currentUser = AccessUtils.getCurrentUser()
const currentUserGroups = AccessUtils.getCurrentUserGroups()
const currentUser = this.getCurrentUser()
const currentUserGroups = this.getCurrentUserGroups()

// Return from the context cache if exists.
if (!force && currentUser && currentUser.getId() === userId) {
Expand Down Expand Up @@ -228,7 +228,7 @@ module.exports = class AccessUtils {
*
* @returns {Object} Returns the currently logged in user.
*/
static getCurrentUser() {
getCurrentUser() {
const ctx = LoopBackContext.getCurrentContext()
const currentUser = (ctx && ctx.get('currentUser')) || null

Expand All @@ -240,7 +240,7 @@ module.exports = class AccessUtils {
*
* @returns {Array} Returnds a list of access groups the user is a member of.
*/
static getCurrentUserGroups() {
getCurrentUserGroups() {
const ctx = LoopBackContext.getCurrentContext()
const currentUserGroups = (ctx && ctx.get('currentUserGroups')) || []

Expand Down

0 comments on commit 495b017

Please sign in to comment.