I’m building a Member site that has a unique sign up that holds Members for approval. That part works with the Wix member database. I now need to build a dashboard for members to update a very long member profile with multiple (+23) fields. I’ve built a new database for all this information which works perfectly. I can use the code below to build the dashboard but I need a “custom” log in because they should not be allowed to “set up” a new account - only log in. I can’t seem to find a way to insert a custom log in to this type of page. I’ve built a Lightbox custom log in but then it won’t work with a page where they can update the new Member database I built - only the existing Wix account member database.
export function loginButton_click(event) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginButton").label = "Login";
$w("#profileButton").hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Members")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Members", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginButton").label = "Logout";
$w("#profileButton").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}