quit userError
This commit is contained in:
parent
63acbc50d5
commit
81752e7f30
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
if (!user)
|
||||
throw new UserError(`This email does not belong to a user`);
|
||||
return;
|
||||
|
||||
const token = await models.AccessToken.create({
|
||||
ttl: ttl,
|
||||
|
@ -54,7 +54,5 @@ module.exports = Self => {
|
|||
title,
|
||||
body
|
||||
]);
|
||||
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -10,17 +10,6 @@ describe('account recoverPassword()', () => {
|
|||
return value;
|
||||
};
|
||||
|
||||
it('should throw an error when email does not belong to a user', async() => {
|
||||
let error;
|
||||
try {
|
||||
await models.Account.recoverPassword(ctx, 'thor@mydomain.com');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual('This email does not belong to a user');
|
||||
});
|
||||
|
||||
it('should update password when it passes requirements', async() => {
|
||||
const user = await models.Account.findById(1107);
|
||||
await models.Account.recoverPassword(ctx, user.email);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||
const md5 = require('md5');
|
||||
const app = require('../../loopback/server/server.js');
|
||||
const dataSources = require('../../loopback/server/datasources.json');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = Self => {
|
||||
|
@ -29,7 +31,8 @@ module.exports = Self => {
|
|||
ctx.data.password = md5(ctx.data.password);
|
||||
});
|
||||
|
||||
Self.observe('before save', async ctx => {
|
||||
Self.observe('before save', async(ctx, instance) => {
|
||||
console.log(instance);
|
||||
const models = Self.app.models;
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const changes = ctx.data || ctx.instance;
|
||||
|
@ -55,12 +58,22 @@ module.exports = Self => {
|
|||
${title}
|
||||
</a>`;
|
||||
|
||||
result = await Self.rawSql(`CALL vn.mail_insert(?,?,?,?)`, [
|
||||
changes.email,
|
||||
null,
|
||||
title,
|
||||
body
|
||||
], ctx.options);
|
||||
const url = app.get('rootUrl') || app.get('url');
|
||||
console.log(app.get('rootUrl'));
|
||||
console.log(app.get('url'));
|
||||
const options = {
|
||||
type: 'email',
|
||||
to: instance.email,
|
||||
from: 'dataSources.email.settings.transports[0].auth.from',
|
||||
subject: title,
|
||||
template: body,
|
||||
redirect: `${origin}#/login/${instance.email}?emailConfirmed`,
|
||||
host: url.hostname,
|
||||
port: url.port,
|
||||
protocol: url.protocol.split(':')[0],
|
||||
user: Self
|
||||
};
|
||||
instance.verify(options);
|
||||
});
|
||||
|
||||
Self.remoteMethod('getCurrentUserData', {
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class App extends Component {
|
|||
|
||||
get showLayout() {
|
||||
let state = this.$state.current.name;
|
||||
return state && !state.includes('login');
|
||||
return state && state != 'login' && !this.isRecover;
|
||||
}
|
||||
|
||||
get isRecover() {
|
||||
|
|
|
@ -233,11 +233,10 @@
|
|||
"Descanso diario 12h.": "Descanso diario 12h.",
|
||||
"Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
|
||||
"Dirección incorrecta": "Dirección incorrecta",
|
||||
"This email does not belong to a user": "Este correo electrónico no pertenece a un usuario.",
|
||||
"Recover password": "Recuperar contraseña",
|
||||
"Click on the following link to change your password.": "Pulsa en el siguiente link para cambiar tu contraseña.",
|
||||
"Verify email": "Verificar correo",
|
||||
"Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Pulsa en el siguiente link para verificar este correo. Si no has pedido este correo, simplemente ignóralo.",
|
||||
"Click on the following link to change your password": "Click on the following link to change your password",
|
||||
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue