I am trying to make an email verification in my project using this tutorial:
https://themeteorchef.com/tutorials/sign-up-with-email-verification
I’ve got method:
//server/methods/send-email.js
import { Meteor } from 'meteor/meteor';
import { Email } from 'meteor/email';
Meteor.methods({
sendVerificationLink() {
let userId = Meteor.userId();
if ( userId ) {
console.log("Email has been sent");
return Accounts.sendVerificationEmail( userId );
}
}
});
And call this method on client side:
//client/form.js
handleSubmit = () => {
this.validateField('phone', this.state.phone)
if (this.state.formValid) {
this.update_User({phone: this.state.phone});
}
Meteor.call( 'sendVerificationLink', ( error, response ) => {
if ( error ) {
console.log(error);
} else {
console.log("- There is no errors in Meteor.call -");
}
});
}
I am getting an email with link. But when I go this link, nothing happens.
Meteor.user().emails[ 0 ].verified - doesn’t become true.
{Meteor.user().emails[ 0 ].verified ? <div>Success</div> : <div>Failed</div>}
I don’t get the Success text.
I’ve tried this:
import { Meteor } from 'meteor/meteor';
Accounts.emailTemplates.siteName = "name";
Accounts.emailTemplates.from = "name<admin@name.io>";
Accounts.emailTemplates.verifyEmail = {
subject() {
return "[name] Verify Your Email Address";
},
text( user, url ) {
let emailAddress = user.emails[0].address,
urlWithoutHash = url.replace( '#/', '' ),
supportEmail = "support@cryptocean.io",
emailBody = `To verify your email address (${emailAddress}) visit the following link:\n\n${urlWithoutHash}\n\n If you did not request this verification, please ignore this email. If you feel something is wrong, please contact our support team: ${supportEmail}.`;
return emailBody;
}
};
Accounts.onEmailVerificationLink = function() {
console.log("Verified");
user.emails[0].verified = true;
}
But it seems I’m doing something wrong.
I am not very experienced in Meteor / backend… So I really hope to find some help here. Imagine cat looking deeply into your soul from “Puss in Boots” movie. That’s me right now))