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