4077-login_recover-password & account_verifyEmail #1063
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
if (!user)
|
||||
throw new UserError(`This email does not belong to a user`);
|
||||
return;
|
||||
alexm marked this conversation as resolved
Outdated
|
||||
|
||||
const token = await models.AccessToken.create({
|
||||
ttl: ttl,
|
||||
|
@ -54,7 +54,5 @@ module.exports = Self => {
|
|||
title,
|
||||
body
|
||||
]);
|
||||
|
||||
return;
|
||||
};
|
||||
};
|
||||
alexm marked this conversation as resolved
Outdated
juan
commented
Aquest return no fa falta ficarlo. Aquest return no fa falta ficarlo.
|
||||
|
|
|
@ -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}
|
||||
alexm marked this conversation as resolved
Outdated
juan
commented
Cridar al métode Cridar al métode `User.verify()` com ací:
* https://gitea.verdnatura.es/juan/hedera-web/src/branch/master/back/common/models/user.js#L22
* https://loopback.io/doc/en/lb2/Registering-users.html
|
||||
</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;
|
||||
alexm marked this conversation as resolved
Outdated
juan
commented
Açò funciona en tots els casos? Que passa si un estat conte login? Açò funciona en **tots** els casos? Que passa si un estat conte login?
|
||||
}
|
||||
|
||||
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
Aixina dones pistes sobre si el correu existeix, si no trova el correu fes
return
de forma que el client es comporte de la mateixa manera. Aquest métode nomes deuria fallar en errors inesperats, que tornarien al client com a HTTP 500 Internal server error