4077-login_recover-password & account_verifyEmail #1063

Merged
alexm merged 52 commits from 4077-login_recover-password into dev 2022-11-28 11:34:03 +00:00
7 changed files with 95 additions and 19 deletions
Showing only changes of commit ce2ad32ac9 - Show all commits

View File

@ -1,4 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('recoverPassword', {
@ -20,7 +20,6 @@ module.exports = Self => {
Self.recoverPassword = async function(ctx, email) {
const models = Self.app.models;
const origin = ctx.req.headers.origin;
const $t = ctx.req.__; // $translate
const ttl = 1209600;
const user = await models.Account.findOne({
@ -38,21 +37,14 @@ module.exports = Self => {
userId: user.id
});
const title = $t('Recover password');
const body = `
<p>
${$t('Click on the following link to change your password')}:
</p>
</b>
<a href="${origin}/#!/account/${user.id}/basic-data?access_token=${token.id}">
${title}
</a>`;
const url = `${origin}/#!/account/${user.id}/basic-data?access_token=${token.id}`;
const params = {
recipient: 'alexm@verdnatura.es',
url: url
};
await Self.rawSql(`CALL vn.mail_insert(?,?,?,?)`, [
email,
null,
title,
body
]);
const sendEmail = new Email('recover-password', params);
return sendEmail.send();
};
};

View File

@ -234,10 +234,8 @@
"Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
"Dirección incorrecta": "Dirección incorrecta",
"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",
"Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
"Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",

View File

@ -0,0 +1,13 @@
const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -0,0 +1,5 @@
.external-link {
border: 2px dashed #8dba25;
border-radius: 3px;
text-align: center
}

View File

@ -0,0 +1,3 @@
subject: Recuperar contraseña
title: Recuperar contraseña
Click on the following link to change your password.: Pulsa en el siguiente link para cambiar tu contraseña.

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html v-bind:lang="$i18n.locale">
<head>
<meta name="viewport" content="width=device-width">
<meta name="format-detection" content="telephone=no">
<title>{{ $t('subject') }}</title>
</head>
<body>
<table class="grid">
<tbody>
<tr>
<td>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
<!-- Header block -->
<div class="grid-row">
<div class="grid-block">
<email-header></email-header>
</div>
</div>
<!-- Block -->
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<p>
{{ $t('Click on the following link to change your password.') }}
<a :href="url">{{ $t('subject') }}</a>
</p>
</div>
</div>
<!-- Footer block -->
<div class="grid-row">
<div class="grid-block">
<email-footer></email-footer>
</div>
</div>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,17 @@
const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
module.exports = {
name: 'recover-password',
components: {
'email-header': emailHeader.build(),
'email-footer': emailFooter.build()
},
props: {
url: {
type: [String],
required: true
}
}
};