@wildhart, thanks for sharing that snippet! That’s very similar to what I’m doing now in React:
const VerifyEmail = (props) => {
const [verifyError, setVerifyError] = useState(null);
const { match, history, userId, client } = props;
const { mutate } = client;
useEffect(() => {
Accounts.verifyEmail(match.params.token, (error) => {
if (error) {
console.warn('VerifyEmail error');
console.warn(error);
Bert.alert(error.reason, 'danger');
setVerifyError(`${error.reason}. Please try again.`);
} else {
setTimeout(() => {
if (userId) {
mutate({
mutation: SEND_VERIFICATION,
variables: { userId },
});
}
Bert.alert('All set, thanks!', 'success');
history.push('/');
}, 1500);
}
});
}, [verifyError]);
return (
<div className="VerifyEmail">
<Alert bsStyle={!verifyError ? 'info' : 'danger'}>
{!verifyError ? 'Verifying...' : verifyError}
</Alert>
</div>
);
};
However, calling SEND_NOTIFICATION is pretty spotty, which is why I started looking for a more clean server-side option. Surprised there isn’t an explicit one, but thanks @coagmano, will have to research Accounts.validateLoginAttempt and see if that does the trick.