Skip to content

Commit 495b017

Browse files
author
Tom Kirkpatrick
committed
fix: make getCurrentUser and getCurrentUserGroups instance methods again
1 parent a187050 commit 495b017

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.eslintrc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
'extends': 'fullcube',
3-
'root': true,
4-
'rules': {
5-
no-console: 0
2+
extends: fullcube,
3+
root: true,
4+
rules: {
5+
no-console: 0,
6+
class-methods-use-this: 0
67
}
78
}

lib/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = class AccessUtils {
5959
if (typeof Model.observe === 'function') {
6060
debug('Attaching access observer to %s', modelName)
6161
Model.observe('access', (ctx, next) => {
62-
const currentUser = AccessUtils.getCurrentUser()
62+
const currentUser = this.getCurrentUser()
6363

6464
if (currentUser) {
6565
// Do not filter if options.skipAccess has been set.
@@ -198,8 +198,8 @@ module.exports = class AccessUtils {
198198
getUserGroups(userId, force, cb) {
199199
force = force || false
200200
cb = cb || createPromiseCallback()
201-
const currentUser = AccessUtils.getCurrentUser()
202-
const currentUserGroups = AccessUtils.getCurrentUserGroups()
201+
const currentUser = this.getCurrentUser()
202+
const currentUserGroups = this.getCurrentUserGroups()
203203

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

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

0 commit comments

Comments
 (0)