#1057 modificar el component vn-user-configuration

This commit is contained in:
Gerard 2019-02-06 12:14:54 +01:00
parent d714c34f59
commit 519350442f
1 changed files with 12 additions and 1 deletions

View File

@ -13,8 +13,19 @@ module.exports = function(Self) {
});
Self.getUserConfig = async ctx => {
return await Self.app.models.UserConfig.findOne({
let userConfig = await Self.app.models.UserConfig.findOne({
where: {userFk: ctx.req.accessToken.userId}
});
if (!userConfig) {
let newConfig = {
warehouseFk: 1,
companyFk: 442,
userFk: ctx.req.accessToken.userId
};
userConfig = await Self.app.models.UserConfig.create(newConfig);
}
return userConfig;
};
};