Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

README.md

Loopback current user component


Base on loopback3 current context package current user for loopback operation hooks

Install

> npm install loopback-component-currentuser

Config

./server/component-config.json

{
  ...
    "loopback-component-currentuser": {
      "filter" : {
        "include": ["userIdentities", "userCredentials"]
     },
     "user": "user"
  }
  ...
}

Usage

'use strict';

module.exports = (Deal) => {
  Deal.observe('before save', (ctx, next)=>{
    if (ctx.instance) {
      if (ctx.isNewInstance) {
        if (ctx.options.accessToken) {
          console.log(ctx.options.currentUser);
        }
      }
      next();
    } else {
      next();
    }
  });
};

About

Loopback.io component currentuser

Resources

Packages

No packages published