关于Meteor中的自定义电子邮件验证
我试图在meteor中编写自己的自定义auth表单。对于电子邮件验证部分,系统发送一封附有路由和令牌的电子邮件。但是,我想在验证页面中获取令牌,因此我厌倦了以下内容关于Meteor中的自定义电子邮件验证,meteor,Meteor,我试图在meteor中编写自己的自定义auth表单。对于电子邮件验证部分,系统发送一封附有路由和令牌的电子邮件。但是,我想在验证页面中获取令牌,因此我厌倦了以下内容 Accounts.onEmailVerificationLink(function(token, done) { console.log("hello"); Session.set(verifyEmailToken, token); doneCallback = done; }); Template.emailVer
Accounts.onEmailVerificationLink(function(token, done) {
console.log("hello");
Session.set(verifyEmailToken, token);
doneCallback = done;
});
Template.emailVerified.onCreated(function(){
console.log(Session.get(verifyEmailToken));
Accounts.verifyEmail(Session.get(verifyEmailToken),function(err){
if(err){
Session.set(ERROR_KEY,err.reason);
}else{
Session.set(SUCESS_KEY,"Your email has been verified, thank you!");
if (doneCallback) {
doneCallback();
}
}
});
});
但是Accounts.onemailvificationlink方法似乎没有被调用。我错过什么了吗?感谢您的帮助。尝试以下方法:
服务器代码:
Accounts.urls.verifyEmail = function(token) {
return Meteor.absoluteUrl('verify/' + token);
};
通用/双路由器:
AccountController = RouteController.extend({
verifyEmail: function() {
Accounts.verifyEmail(this.params.token, function(err) {
if (err) {
// error
} else {
//
}
});
}
});
Router.map(function() {
return this.route('verifyEmail', {
controller: 'AccountController',
path: '/verify/:token',
action: 'verifyEmail'
});
});
谢谢,比娅。是否有一种方法可以在模板级别执行此操作?我试图最小化路由器逻辑。