var logger = require("log4js").getLogger("angoose");
var logger = require("log4js").getLogger("angoose");
This class encapsulates authenticated user information.
To obtain an instance of this object, you may use getContext
method
defined on the Model/Service class or instance:
MySchema.methods.updateStatus = function(){
var user = this.getContext().getPrincipal();
console.log("User is ", user.getUsername());
}
var Principal = function(userId, username, roles){
var user = {
_id: userId,
username: username,
roles:roles
}
this.getUsername = function(){ return user.username};
this.getRoles = function(){ return user.roles};
this.getUserId = function(){ return user.userId};
};
module.exports = Principal;