#6274 workerTimeControl #1858
|
@ -200,5 +200,6 @@
|
|||
"Try again": "Try again",
|
||||
"keepPrice": "keepPrice",
|
||||
"Cannot past travels with entries": "Cannot past travels with entries",
|
||||
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}"
|
||||
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
|
||||
"Incorrect pin": "Incorrect pin."
|
||||
}
|
||||
|
|
|
@ -331,8 +331,7 @@
|
|||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||
"Incorrect pin.": "Pin incorrecto.",
|
||||
"Incorrect pin": "Pin incorrecto.",
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||
"The alias cant be modified": "Este alias de correo no puede ser modificado"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('login', {
|
||||
Self.remoteMethodCtx('login', {
|
||||
description: 'Consult the user\'s information and the buttons that must be activated after logging in',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
|
@ -21,14 +21,15 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.login = async(pin, options) => {
|
||||
Self.login = async(ctx, pin, options) => {
|
||||
const myOptions = {};
|
||||
const $t = ctx.req.__;
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const query = `CALL vn.workerTimeControl_login(?)`;
|
||||
const [[user]] = await Self.rawSql(query, [pin], myOptions);
|
||||
if (!user) throw new UserError('Incorrect pin.');
|
||||
if (!user) throw new UserError($t('Incorrect pin'));
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
Falta traduccion Falta traduccion
|
||||
return user;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('workerTimeControl login()', () => {
|
||||
let ctx;
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
No hace falta pasar el objeto No hace falta pasar el objeto
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
accessToken: {userId: 9},
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: key => key
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx
|
||||
});
|
||||
});
|
||||
|
||||
it('should correctly login', async() => {
|
||||
const response = await models.WorkerTimeControl.login(9);
|
||||
const response = await models.WorkerTimeControl.login(ctx, 9);
|
||||
|
||||
expect(response.name).toBe('developer');
|
||||
});
|
||||
|
||||
it('should throw UserError if pin is not provided', async() => {
|
||||
try {
|
||||
await models.WorkerTimeControl.login();
|
||||
await models.WorkerTimeControl.login(ctx);
|
||||
} catch (error) {
|
||||
expect(error).toBeInstanceOf(UserError);
|
||||
expect(error.message).toBe('Incorrect pin.');
|
||||
expect(error.message).toBe('Incorrect pin');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
ayer no hablamos de no poner puntos? son estos casos?
cierto