The weasl.onEmailVerify Function

You might have noticed that the weasl JavaScript functions won't return a promise unless Weasl has been fully loaded on the page. You might need to do asynchronous work - things that depend on Weasl having loaded. Getting the current user, for example. Just like the weasl.onload callback function, you can make a weasl.onEmailVerify callback. This function will be called when the user lands on your website after clicking through a magiclink login button they were received via email.

weasl.onEmailVerify = function(weaslApi) {
  // this.getCurrentUser() also works
  weaslApi.getCurrentUser().then(function(currentUser) {
    window.loggedIn = true;
    window.user = currentUser;
  }.catch(() => window.loginFailed = true);
};

Did this help answer your question?

thumbs up
thumbs down

Thanks for the feedback! 🙏🏽


Help by drift