To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/63d2ebb8-e148-4242-9ac8-f650196ffcff%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/A9gT2ZLuges/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/524f1e27-8a7f-4fee-8425-d8647c19ba7c%40googlegroups.com.
var template = loopback.template(options.template);
options.html = template(options);
Email.send(options, function(err, email) {
if (err) {
fn(err);
} else {
fn(null, {email: email, token: user.verificationToken, uid: user.id});
}
});<%= user.name %>module.exports = function(UserW) { UserW.afterRemote('create', function(context, UserW, next) { console.log('> UserW.afterRemote triggered');
var options = { type: 'email', to: UserW.email, from: 'nor...@loopback.com', subject: 'Gracias por registrarte.', // template: path.resolve(__dirname, '../../server/views/verify.ejs'), redirect: 'http://localhost:9000/#/login', user: UserW, // text: 'Gracias por registrarte. Por favor, sigue el siguiente link para completar tu registro.\n\t{href}', href: "{href}" };
UserW.verify(options, function(err, response) { if (err) return next(err);
console.log('> verification email sent:', response); return response; context.res.render('response', { title: 'Registro exitoso!', content: 'Por favor, revisa tu correo y verificate antes de entrar al sistema. ', redirectTo: 'http://localhost:9000/#/login', redirectToLinkText: 'Log in' }); }); });};User.afterRemote('create', function(context, user, next) {
var verifyLink = 'https://' +
hostAddress +
':' +
portNumber +
restApiRoot +
'/Users/confirm' +
'?uid=' +
user.id +
'&redirect=https://' + hostAddress + '/verified?user_id='+user.id;
logger.verbose("Link: " + verifyLink);
var options = {
type: 'email',
mailer: Email,
to: user.email,
from: serviceEmail,
subject: 'User registration confirmation',
template: path.resolve(__dirname, '../views/verify.ejs'),
//text: 'Thanks for registering! Click here for verification: \n\t{href}',
user: user,
verifyHref: verifyLink,
//protocol: 'https',
//host : hostAddress,
//port : portNumber,
host: serviceEmailHost,
port: serviceEmailPort
};
user.verify(options, function(err, response) {
if (err) {
next(err);
return;
}
logger.verbose("Account verification email sent to " + options.to);
next();
return;
});
//more code
//...
//...
});
}