我正在使用邀请宝石,用户可以在其中邀请其他用户加入组织。创建邀请时,它会生成安全令牌,但是当我将其传递给url时,它不会显示。
这是我的邀请邮件。如您所见,即时消息将url令牌传递给了网址。
const Promise = require("bluebird");
const fs = require("fs");
const Client = require("ssh2-sftp-client");
const util = require("util");
const sftp = new Client();
const path = require("path");
const openpgp = require("openpgp"); // use as CommonJS, AMD, ES6 module or via window.openpgp
openpgp.initWorker({
path: "openpgp.worker.js"
}); // set the relative web worker path
const config = {
host: 'xxxx',
port: '1111',
username: 'xxxx',
password: 'xxxx'
};
function getFileFromSFTP() {
console.log("Program Execution started");
/* get files from SFTP */
const remotePath = "remoteFile";
const localPath = "localFile"
sftp.connect(config).then(() => {
sftp.get(remotePath, true, null).then((data) => {
data.on('error', (e) => {
console.log(e);
});
data.on('end', () => {
console.log("rs end");
});
data.on('close', () => {
console.log("rs closed");
});
data.pipe(fs.createWriteStream(localPath).on('error', (e) => {
console.log(e);
}).on('finish', () => {
console.log("ws finish");
}).on('close', () => {
console.log("ws close");
}));
});
});
}
function init() {
getFileFromSFTP();
}
init();
这是我的Invitation_mailer / _new.html.erb
> node index.js
Program Execution started
rs end
ws finish
ws close
rs closed
这是控制台中打印出的内容。
def new_user(invite)
@invite = invite
@user_registration_url = Invitation.configuration.user_registration_url.call(invite_token: @invite.token)
mail(
from: Invitation.configuration.mailer_sender,
to: @invite.email,
subject: I18n.t('invitation.invite_mailer.new_user.subject')
)
end
这就是我收到的电子邮件
test@gmail.com邀请您在http://localhost:3000/上#。您可以使用下面的网址接受邀请。
邀请配置
<p><%= t('invitation.invite_mailer.new_user.hello', email: @invite.email) %></p>
<p><%= raw t('invitation.invite_mailer.new_user.someone_invited_you',
sender: @invite.sender.email, invitable: @invite.invitable.invitable_name, url: root_url) %></p>
<p><%= @user_registration_url %></p>
<p><%= t('invitation.invite_mailer.new_user.ignore').html_safe %></p>