import { Accounts } from 'meteor/accounts-base'
// The following goes into onRendered (for Blaze) or equivalent in React - useEffect(() => , [])
// Pick up the token from the url.
// Check that your are logged in (the status is: logged in and email is not confirmed)
Accounts.verifyEmail(token, err => {
if (err?.reason === 'Verify email link expired') {
// notify user the link is expired
}
if (err) {
// your preferred logger
log('Could not verify email!', `Error: ${err.reason}`)
} else {
log('You\'ve Successfully Confirmed Your Email Address!')
// your router or history function to direct to a valid route after login. Your curent route is probably '/verify-email/:token' or similar.
history.push('/home')
}
Indeed what you’ve send works fine and I am able to verify an account. I just wonder what’s the point of having an onEmailVerificationLink function (which by the way I haven’t been able to use properly so far) that can register what happens when a verification link is clicked if we can handle that into a component related to the verification process.
Is it a better practice to handle that with the onEmailVerificationLink function or is it okay to handle the whole process within the React component.