diff --git a/back/methods/account/recover-password.js b/back/methods/account/recover-password.js index b0923b61b..ac89027c4 100644 --- a/back/methods/account/recover-password.js +++ b/back/methods/account/recover-password.js @@ -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 = ` -

- ${$t('Click on the following link to change your password')}: -

- - - ${title} - `; + 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(); }; }; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b6d806608..174f5921e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -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", diff --git a/print/templates/email/recover-password/assets/css/import.js b/print/templates/email/recover-password/assets/css/import.js new file mode 100644 index 000000000..7360587f7 --- /dev/null +++ b/print/templates/email/recover-password/assets/css/import.js @@ -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(); + diff --git a/print/templates/email/recover-password/assets/css/style.css b/print/templates/email/recover-password/assets/css/style.css new file mode 100644 index 000000000..5db85befa --- /dev/null +++ b/print/templates/email/recover-password/assets/css/style.css @@ -0,0 +1,5 @@ +.external-link { + border: 2px dashed #8dba25; + border-radius: 3px; + text-align: center +} \ No newline at end of file diff --git a/print/templates/email/recover-password/locale/es.yml b/print/templates/email/recover-password/locale/es.yml new file mode 100644 index 000000000..c72b108ee --- /dev/null +++ b/print/templates/email/recover-password/locale/es.yml @@ -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. diff --git a/print/templates/email/recover-password/recover-password.html b/print/templates/email/recover-password/recover-password.html new file mode 100644 index 000000000..a654b3d5f --- /dev/null +++ b/print/templates/email/recover-password/recover-password.html @@ -0,0 +1,48 @@ + + + + + + {{ $t('subject') }} + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

+ {{ $t('Click on the following link to change your password.') }} + {{ $t('subject') }} +

+
+
+ + +
+
+ +
+
+ +
+
+
+
+ + diff --git a/print/templates/email/recover-password/recover-password.js b/print/templates/email/recover-password/recover-password.js new file mode 100755 index 000000000..b589411a9 --- /dev/null +++ b/print/templates/email/recover-password/recover-password.js @@ -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 + } + } +};