Hello!
So, I have created a Lightbox to create custom login and signup page. The only way to access my forum is to login. The signup Lightbox works perfectly. When a user signs up, they enter their password, email and some other details which gets stored into a database but the password does not get stored and is in stead sent to the wix CRM. After reading the information, I accept or reject the registration request.
When a user has been accepted and wants to login, they would have to enter the email and password. Then, they click on the login button. If they are in the CRM, they are directed to the forum, otherwise they are asked to try again. I have used the following code but it doesn't work and fulfill my needs. Could someone kindly help me in this?
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
// ...
$w.onReady(function () {
$w('#login').onClick( () => {
wixUsers.promptLogin()
.then( (user) => {
let email = $w('#email');
let isLoggedIn = user.loggedIn; // true
let userRole = user.role;
let password= $w('#password'); // "member"
return user.getEmail();
} )
.then( (email) => {
let userEmail = email; // "user@something.com"
} )
.catch( (err) => {
let errorMsg = err; // "The user closed the login dialog"
})
})
})