Client: add notes
This commit is contained in:
parent
64497d70e1
commit
a58d530523
|
@ -1,7 +1,4 @@
|
|||
module.exports = function(Self) {
|
||||
|
||||
let loopBackContext = require('loopback-context');
|
||||
|
||||
Self.validate('text', isEnabled, {message: 'Se debe rellenar el campo de texto'});
|
||||
function isEnabled(err) {
|
||||
if (!this.text) err();
|
||||
|
@ -9,15 +6,15 @@ module.exports = function(Self) {
|
|||
|
||||
Self.observe('before save', function(ctx, next) {
|
||||
ctx.instance.created = Date();
|
||||
let currentUser = loopBackContext.getCurrentContext();
|
||||
let userId = currentUser.get('currentUser');
|
||||
let app = require('../../server/server');
|
||||
let Employee = app.models.Employee;
|
||||
Employee.findOne({where: {userFk: userId}}, function (err, user){
|
||||
let token = ctx.options.accessToken;
|
||||
let userId = token && token.userId;
|
||||
let app = require('../../server/server');
|
||||
let Employee = app.models.Employee;
|
||||
Employee.findOne({where: {userFk: userId}}, function (err, user){
|
||||
if (user){
|
||||
ctx.instance.employeeFk = user.id;
|
||||
next();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue