1
私はParse-Serverとmailgunのクラウドコードを使用して電子メールにサインアップまたは変更するユーザーに電子メール確認コードを送信しています。PFUserの "email"フィールドが変更されているかどうかを知るためにDirtyKeysを使用する方法?
BeforeSave方法:今、ユーザーが任意の提出を変更する毎回メールを送信され
Parse.Cloud.beforeSave(Parse.User, function(request, response) {
var verificationCode = Math.floor(Math.random()*999999);
var text = "Hi ... this is a verification code:" + verificationCode;
var data = {
from: 'WBP Team <[email protected]>',
to: request.object.get("email"),
subject: 'Please verify your e-mail for you Account',
text: text
};
mailgun.messages().send(data, function (error, body) {
if (error) {
response.error("Email not sent..."+error);
}else{
var user = Parse.User.current();
user.set("emailVerificationCode", verificationCode);
user.save();
response.success("Email Sent");
}
console.log(body);
});
});
。しかし、ユーザーが電子メールを変更した場合にのみ、このメソッドを使用したいと考えています。
ありがとうございます!私はそれを解決した:) – Kingofmit