feat: refs #6868 refs# 6868 handleUser
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Sergio De la torre 2024-09-03 16:50:55 +02:00
parent a82df8e2a2
commit 36cf6b1aee
4 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,6 @@ module.exports = Self => {
require('../methods/account/logout')(Self); require('../methods/account/logout')(Self);
require('../methods/account/change-password')(Self); require('../methods/account/change-password')(Self);
require('../methods/account/set-password')(Self); require('../methods/account/set-password')(Self);
require('../methods/account/handle-user')(Self);
Self.setUnverifiedPassword = async(id, pass, options) => { Self.setUnverifiedPassword = async(id, pass, options) => {
const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options);

View File

@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
describe('Account handleUser()', () => { describe('Device handleUser()', () => {
const ctx = {req: {accessToken: {userId: 9}}}; const ctx = {req: {accessToken: {userId: 9}}};
it('should return data from user', async() => { it('should return data from user', async() => {
@ -9,7 +9,7 @@ describe('Account handleUser()', () => {
const nameApp = 'warehouse'; const nameApp = 'warehouse';
const versionApp = '10'; const versionApp = '10';
const data = await models.Account.handleUser(ctx, androidId, deviceId, versionApp, nameApp); const data = await models.Device.handleUser(ctx, androidId, deviceId, versionApp, nameApp);
expect(data.numberOfWagons).toBe(2); expect(data.numberOfWagons).toBe(2);
}); });

View File

@ -1,6 +1,7 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
require('../methods/device/handle-user')(Self);
Self.rewriteDbError(function(err) { Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY') if (err.code === 'ER_DUP_ENTRY')
return new UserError(``); return new UserError(``);