Database password field check.

Hi.

I have created a signup page where I gather 4 ‘user input’ fields which includes username and password.

I want to create another page where they will have to login.

How do I check through at the data I have in the database to see if they have signed up?

Is there some kind of way to get WIX to run down all the records and say yes or no depending on what it finds?

I don’t really want to use the provided member area way because I don’t think it looks right (am not sure how to access that data or where it goes).

Thanks if you can help, ste.

Just create your own signup and login lightboxes so that you can call them where ever you need them on your site by changing your custom sign up settings.
https://support.wix.com/en/article/corvid-enabling-custom-site-registration

My custom login lightbox code:

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
 $w("#forgotPassword").onClick( (event) => {
    //wixWindow.lightbox.close()
   wixUsers.promptForgotPassword()
   .then( ( ) => {
   //
   } )
    .catch( (err) => {
 let errorMsg = err;  //"The user closed the forgot password dialog"
    });
 });
});

export function loginButton_click(event) {

 let email = $w("#email").value;
 let password = $w("#password").value;

 wixUsers.login(email, password)
   .then( () => {
     console.log("User is logged in");
     wixLocation.to("/account/my-account");  //Change the URL ending to whatever page you want to send the user to after they log in.
   } )
    .catch( (err) => {
     console.log(err);
     $w("#errorMessage").expand();  // You can delete this line if you are not going to add an error message.  Use a regular text element set to 'collapse on load' from the Properties Panel.
   } ); 
}

My custom signup lightbox code:

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
    
    $w("#registerButton").onClick( (event) => {
        
   let email = $w("#email").value;
   let password = $w("#password").value;
   let first = $w("#firstName").value;
   let last = $w("#lastName").value;

   wixUsers.register(email, password, {
       contactInfo: {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
       }
      } )
      .then( (result) => {
        let resultStatus = result.status;
  wixWindow.lightbox.close();
  wixLocation.to("/sign-in-status");  //Change the URL ending to whatever page you want to send the user to after they log in.
      } );     
    } );
    
});

This works perfectly and closes after registering details before moving them onto my signup status page, then both names will be saved in contacts and once site member is approved the member details will be added to my ‘members’ database.

As for using the Wix Members App, that gets stored on the dataset called Memmbers/PrivateMembersData, of which you can read the data from if you want to use it.
Velo: Wix Members "PrivateMembersData" Collection Fields | Help Center | Wix.com
If you ever use it in code then you must add it with the members at the front nad not just simply private…

I use both the Wix Members app and my own members dataset on my site, however I don’t have the Wix Members Login bar anywhere on my site, I simply have the login button purely on my members only page with this being the only place my members can login or logout.

This allows me to have all the Wix Member app features like My Account page etc.
Setting up a Members Area | Help Center | Wix.com

However, it also allows me to create member profile pages for example where each user can add their own inputs that only themselves can access.
Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com

I also used the code in the above tutorial to base my members only page on, so that instead of the code taking you to your members profile page, mine instead keeps me on my members only page and simply refreshes the page so that the code on the page will work and the login button will change its value to logout and the members only strips will be shown.

This is the code for my members only page which is based on the own members area tutorial from Wix, so you can use the code example from the tutorial to suit your own needs.

All my member only elements are contained in a strip which makes it much easier to use in the code instead of having to copy and paste lots of elements for show and hide.

The white gap for footer strip is there so that when the members are not logged in the page doesn’t show anything apart from a logo and the login button, so this strip is expanded onto the page so that the footer rests at the bottom of it, which then displays perfectly on the viewing device with the footer aligned at the bottom of the viewable screen in either desktop or mobile viewing.

Without this, you could potentially end up with a big white gap on your page where the page items should be and the footer would be only visible if you scrolled down the screen manually, which of course makes the layout of the page look awful!

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#loginbutton").label = "Logout";
$w("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();

}
else {
$w("#loginbutton").label = "Login";
$w("#membersareaonlystrip").collapse();
$w("#whitegapforfooter ").show();

}
} );

export function loginbutton_onclick(event) { 
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginbutton").label = "Login";
  $w("#membersareaonlystrip").collapse();
  $w("#whitegapforfooter ").show();

} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in 
wixUsers.promptLogin( {"mode": "signup"} )
.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("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();

} )
.catch( (err) => {
console.log(err);
} );
}
}

export function profilebutton_onclick(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`); 
}

export function entermembersbutton_onclick(event) {
wixLocation.to(`/members-area`); 
}

export function myaccountbutton_onclick(event) {
wixLocation.to(`/account/my-account`); 
}

export function websiteupdatebutton_onclick(event) {
wixLocation.to(`/website-update`); 
}

That is way and above what I expected, thank you so much!

I’m going to dig my teeth into it over the weekend.

Much appreciated, enjoy the sun!

You’re a legend, ste. :slight_smile: