Hello,
I’m trying to integrate the Email/Password functionality into my app and am a bit confused on how it all works. Would like to have a solid understanding to get comfortable with security of the app.
- In my
Accounts.onCreateUser
function, I callAccounts.sendVerificationEmail(user._id);
However, the user doesn’t exist in the database yet apparently…so that call throws an exception.
I’d like to ensure the user is in the DB before I send the email…is this possible inside onCreateUser
, without the following process: (Accounts.createUser
has a callback, and from there I could call a Method that calls the sendVerificationEmail
)?
Or is that the intended process?
-
I currently don’t have a FlowRouter route (to catch the /verify-email/ pattern), but everything (except #3 below) seems to work. How come?
-
Accounts.onEmailVerificationLink
takes a function w/ 2 arguments, and the second argument (doneVerifying
) is a function that should be called after the email has been verified. However, in my code below, it doesn’t get called. Am I using this infrastructure properly?
var doneVerifying = function(){
console.log("in doneVerifying");
if(Meteor.user() && Meteor.user().emails[0].verified){
console.log("success");
}
else{
console.log("failed");
}
}
Accounts.onEmailVerificationLink(function(token, doneVerifying){
//check token using this Meteor-provided function; logs user in afterwards
Accounts.verifyEmail(token, function(error){
if(error){
console.log("error verifying");
}
else{
console.log("email verified");
doneVerifying();
}
});
});
Many thanks for any help.