Question:
How can I have the Promise return automatically, rather than on User input, in order to prohibit or cease the promptLogin code from triggering on page load?
Product:
Velo API on Wix Editor
What are you trying to achieve:
I have created a custom login for my website to manage member access. However, now every time a user views my homepage, it prompts them to log in. I only want the login page to appear when the user clicks the “Log In” button on my homepage, not automatically. I know that the authentication flow from Velo fires based on the following code when the page loads, but my knowledge of how Promises work is rusty. How can I have the Promise return automatically, rather than on User input, in order to prohibit or cease the promptLogin code from triggering on page load?
import { authentication } from 'wix-members-frontend';
// ...
// Sample options value:
// {
// mode: 'login',
// modal: true
// }
authentication.promptLogin(options)
.then(() => {
console.log('Member is logged in');
})
.catch((error) => {
console.error(error);
});
What have you already tried:
(https://www.wix.com/velo/reference/wix-members-frontend/authentication/promptlogin)
Additional information:
If promptLogin cannot be overrided, is there a way where I can simulate a user’s click event to close the lightbox and return to the homepage? Or redirect them from the login to the homepage altogether?