我尝试使用parse-server-mandrill-adapter为忘记密码的用户生成新密码。
我正在使用parse-server,我正在使用parse unbuilt函数requestPasswordReset为用户生成邮件。我设法使用parse-server-mandrill-adapter成功地将电子邮件发送给用户,但是我无法获得有关此用户所包含的任何数据。 例如用户名,appname等字段不会填充。
解析服务器index.js
emailAdapter: {
module: 'parse-server-mandrill-adapter',
options: {
// API key from Mandrill account
apiKey: process.env.MANDRILL_API_KEY || '',
// From email address
fromEmail: 'kontakt@bonsai.se',
// Display name
displayName: 'no-reply@bonsai.se',
// Reply-to email address
replyTo: 'no-reply@bonsai.se',
// Verification email subject
verificationSubject: 'Please verify your e-mail for *|appname|*',
// Verification email body
verificationBody: 'Hi *|username|*,\n\nYou are being asked to confirm the e-mail address *|email|* with *|appname|*\n\nClick here to confirm it:\n*|link|*',
// Password reset email subject
passwordResetSubject: 'Password Reset Request for *|appname|*',
// Password reset email body
passwordResetBody: 'Hi apa *|username|*,\n\nYou requested a password reset for *|appname|*.\n\nClick here to reset it:\n*|link|*'
}
main.js文件,其中调用了requestPasswordReset函数,包含电子邮件,选项和回调。
var query = new Parse.Query(Parse.User)
query.equalTo("email", request.params.email)
query.first({
useMasterKey: true
}).then(function (user) {
Parse.User.requestPasswordReset(request.params.email, {
options: {
"username": "test",
useMasterKey: true
}
}).then(function (success) {
console.log(success)
response.success("success")
}, function (error) {
console.log(error)
response.error("error")
});
})
电子邮件的外观。
答案 0 :(得分:0)
看看:https://github.com/ParsePlatform/parse-server 电子邮件验证和密码重置
同样类似的问题&回答: Parse open source server reset password error
我使用开放式解析服务器中包含的MailGun适配器,就像魅力一样!
答案 1 :(得分:0)
我能够使用parse-server-mandrill-adapter
,并通过正确替换电子邮件/ appname / link成功重置用户密码:
1)安装parse-server-mandrill-adapter
,(将其添加到package.json
以便能够将其部署到远程服务器上。)
2)更新您的index.js
以支持emailAdapter
,source link:
var server = ParseServer({
...
// App Name
appName: 'YourAppName',
// Environment where the user can confirm his e-mail address or reset his password (most likely the same as your 'serverURL')
publicServerURL: 'YourPublicServerURL',
emailAdapter: {
module: 'parse-server-mandrill-adapter',
options: {
// API key from Mandrill account
apiKey: 'API-KEY',
// From email address
fromEmail: 'no-reply@yourdomain.com',
// Display name
displayName: 'no-reply@yourdomain.com',
// Reply-to email address
replyTo: 'no-reply@yourdomain.com',
// Verification email subject
verificationSubject: 'Please verify your e-mail for *|appname|*',
// Verification email body
verificationBody: 'Hi *|username|*,\n\nYou are being asked to confirm the e-mail address *|email|* with *|appname|*\n\nClick here to confirm it:\n*|link|*',
// Password reset email subject
passwordResetSubject: 'Password Reset Request for *|appname|*',
// Password reset email body
passwordResetBody: 'Hi *|username|*,\n\nYou requested a password reset for *|appname|*.\n\nClick here to reset it:\n*|link|*'
}
}
...
});
3)密码重设码:
Parse.User.requestPasswordReset(userEmail, {
success: function() {
// success
},
error: function(error) {
// error
}
});
4)确保在运行该代码时,您的应用程序是从远程服务器运行的,在localhost:1337上运行时我失败了!