我目前正在尝试运行
member.verify()
从我的环回应用程序中,电子邮件发送绝对正常,除了在以下方式格式化网址: -
http://https://example.api.com:port
members.js在创建新成员时发送以下代码: -
Member.afterRemote('create', function(context, member, next) {
console.log('Sending Verification Email');
var options = {
type: 'email',
to: member.email,
from: 'noreply@example.com',
subject: 'Thanks for registering.',
template: path.resolve(__dirname, '../../server/views/verify.ejs'),
redirect: 'https://' + config.host + '/login?verified=true',
user: member
};
member.verify(options, function(err) {
console.log('Verification Email sent:', member, options, err);
if (err){
next(err);
}else{
next();
}
});
});
verify.ejs只包含: -
This is the html version of your email.
<strong><%= text %></strong>
是否有其他人有此问题或知道如何解决?
也有人知道如何从URL的末尾删除端口号吗?
如果您需要任何其他信息,请告诉我们。
编辑: -
我在API的node_modules / loopback / common / models / user.js中找到了以下代码
var displayPort = (
(verifyOptions.protocol === 'http' && verifyOptions.port == '80') ||
(verifyOptions.protocol === 'https' && verifyOptions.port == '443')
) ? '' : ':' + verifyOptions.port;
var urlPath = joinUrlPath(
verifyOptions.restApiRoot,
userModel.http.path,
userModel.sharedClass.findMethodByName('confirm').http.path
);
verifyOptions.verifyHref = verifyOptions.verifyHref ||
verifyOptions.protocol +
'://' +
verifyOptions.host +
displayPort +
urlPath +
'?' + qs.stringify({
uid: '' + verifyOptions.user[pkName],
redirect: verifyOptions.redirect,
});
有什么方法可以覆盖这些信息吗?
答案 0 :(得分:0)
好的,我已设法使用以下方法解决此问题: -
var options = {
type: 'email',
to: member.email,
from: 'noreply@clientplan.com',
subject: 'Thanks for registering.',
template: path.resolve(__dirname, '../../server/views/verify.ejs'),
redirect: 'https://client-plan-app.herokuapp.com/admin',
user: member,
protocol: 'https',
port : '443'
};
我添加了以下行来解决此问题: -
protocol: 'https',
port : '443'