Moving to a next page after Signup, Login and Logout

I copied some login code from some other platform and the following features are missing on the code and I can not do it myself. After SignUp and Login I want users to be directed to a page with name ‘Dashboard’ and when they Logout I want them to be redirected to my Home page. The following is my code: Help…

# 

// For full API documentation, including code examples, visit http://wix.to/94BuAAs

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(“#profileButton”).show();
}
else {
$w(“#loginButton”).label = “My Account”;
//$w(“#profileButton”).hide();
}
} );

export function loginreg_click(event) {
//Add your code for this event here:
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#loginButton”).label = “My Account”;
//$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”;
wixLocation.to.to(‘/Dashboard’);
//$w(“#profileButton”).show();
} )
.catch( (err) => {
console.log(err);
} );
}
}

When you mention about logging in, logging out and signup, well the code you have used in your post is from the tutorial about making your own custom members profile area.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Have a read of this tutorial as this is not for making your own custom login and signup lightboxes and neither does it feature a custom logout function either.

It is simply to create a members profile page which being dynamic is unique to that user and only they themselves can access it and edit or alter anything on their update page too.

This profile page and update profile page can be anything you want it to be, it doesn’t have to be kept as a member profile page, it can be your member dashboard page etc, or whatever you want to put on that page yourself, the choice is yours and you are not restricted to what Wix have put on the tutorial itself.

Plus Nayeli (Code Queen) already has an youtube video which takes you through this tutorial, along with her own website page about it that you can check out yourself.
https://www.youtube.com/watch?v=Orl8GJNzG5s - from 2017
https://www.youtube.com/watch?v=yLCOqsVHhD0 - updated version from 2018
https://codequeen.wixsite.com/membership-dashboard

As for logging out the user and redirecting to another page, then you can simply add a logout button as Steve has suggested in this great previous post here.
https://www.wix.com/corvid/forum/community-discussion/this-is-how-to-logout-and-go-to-the-page-of-your-choice

As for moving a user onto another page after they have logged themselves in or signed themselves up, well this is done in code through the Wix Location API and the .to() function from it, see here for an example of the API reference and it’s functions, you will also notice it in the code that you have used too.
https://www.wix.com/corvid/reference/wix-location.html#to

As for signup and logins, you can either use Wix own window or the custom signup through Wix Forms options, or you can create your own custom login and signup lightboxes.
https://support.wix.com/en/article/about-the-member-signup-form
https://support.wix.com/en/article/editing-your-member-signup-settings-for-the-default-form
https://support.wix.com/en/article/creating-a-custom-signup-form-for-your-members-area

If you do the custom lightbox method, then you need to change your member signup settings to suit your own custom lightboxes.
https://support.wix.com/en/article/about-the-member-signup-form#corvid-form

As for custom lightboxes, they are easy to do yourself, again Nayeli (Code Queen) has a great video tutorial that you can watch and view our own website about it too.
https://www.youtube.com/watch?v=QbH8_eudjbE
https://support.totallycodable.com/en/article/create-custom-log-in-sign-on-screen-using-wix-code

This is the code on my own custom signup lightbox.

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

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 is the code from my login lightbox.

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.
   } ); 
}

@givemeawhisky your sign up code doesn’t work for me. I’m getting messages that none of the IDs in your code exist on the page.

@jillycnolan GOS is not an active member anymore.
You better should open your own post with your own issue.