Login issue- Cannot direct to dynamic page after login

Hello everyone,
I have issue when trying to login using email and password in database named “Profile”. What I want is after login, it will direct to dynamic page where user can edit their own profile. I follow this tutorial
but it shows error 404 when login.

Much appreciate if someone can help me. I attached my coding and dynamic page url

Thank you so much.

1 Like

Try this →

.then(() => {
 wixLocation.to(`/members/update/${email}`);
});

Hello Ajit Kumar,
Thank you for your reply. Unfortunately, it also not work. Do you have any other solution?

2 Likes

@aphrsmgmtsb Have you tried removing the “s” from the his answer above
like this
change this:

.then(() => {
 wixLocation.to(`/members/update/${email}`);
});

to:

.then(() => {
 wixLocation.to(`/member/update/${email}`);
});
1 Like

@okeyiwobi Yeah I remove the ‘s’

1 Like

You have to change the {Email} to {email}

.then(() => {
 wixLocation.to(`/member/update/${email}`);
});

…as you assign the value in the loginEmail input as the variable - email, in your code

let email = $w('#loginEmail').value;

Hi Ajit,
I changed {Email} to {email} but still not work. The button like no function and not going to dynamic page. Do i need to make new database which is only for email and password? Like different database from dynamic database? Because now, email and password that I use to login is in the dynamic database named “Profile”.

I think you are trying to redirect a user to a dynamic page - the database “Profile”…

So dynamic pages are instituted from the respective fields in the databse…
For instance →
There are two fields in your databse…
Field 1 - email
Field 2 - password
So you set the dynamic page’s link structure something like
/member/update/${ email }
So every email in the database have a respective dynamic page…

So, only if the email exist in the database the link will be there…

https://support.wix.com/en/article/about-dynamic-pages-448873

For your case, can you please provide your register page code or the screen shot of your database

@ajithkrr Yeah you’re right. I want to redirect to dynamic page with respective email so that they can review and edit the page. This is my code for register,login and database.

@aphrsmgmtsb Mate !!
I found, in your code, a mistake…
In your register Page you should use the register() function

let email = $w('#emailSignUp').value;
let password = $w('#passwordSignUp').value;

wixUsers.register(email, password)  
 .then( () => {
  wixLocation.to(`/resumepage`);
    
  });

More importantly you should not connect any of the elements to the dataset…

… and can you provide your database fields

@ajithkrr oh really. Thank you so much for helping. I try to change the code. This is profile database.

@ajithkrr I change the code but it come out this error.

Mate !!!
The APIs in wix-users ( register() and login() ) are only partially functional when previewing your site. View a published version of your site to see their complete functionality.
https://www.wix.com/corvid/reference/wix-users/introduction

Now in your register page you should add the insert function

let email = $w('#emailSignUp').value;
let password = $w('#passwordSignUp').value;

wixUsers.register(email, password)  
 .then( () => {
	let toInsert = {
  "email":        email,
  "password":   password
};

wixData.insert("Profile", toInsert)
	.then( (results) => {
	wixLocation.to(`/resumepage`);
		
	}) ;
	  });

Now In your login page →

let email = $w('#loginEmail').value;
let password = $w('#loginPassword').value;

wixUsers.login(email, password)
.then(() => {
 wixLocation.to(`/member/update/${email}`);
});

Hi mate, Thank you so much for the reply just now. I try to register and create profile everything is fine. But, when I login, it come out error like this. And at published site, nothing happened. Do you have any idea?

1 Like

@aphrsmgmtsb Make sure you are using the correct one →

wixLocation.to(`/member/update/${email}`);

There should be a /

@ajithkrr I used the correct one but still cannot locate :frowning:

@aphrsmgmtsb What is your code ??

@ajithkrr import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;
import wixData from ‘wix-data’ ;

$w.onReady( () => {

})

export function button142_click(event) {

let email = $w( ‘#loginEmail’ ).value;
let password = $w( ‘#loginPassword’ ).value;

wixUsers.login(email, password)
.then(() => {

wixLocation.to( ‘/member/update/${email}’ );

});
}

I try this one also.
import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;
import wixData from ‘wix-data’ ;

$w.onReady( () => {

})

export function button142_click(event) {

let email = $w( ‘#loginEmail’ ).value;
let password = $w( ‘#loginPassword’ ).value;

wixUsers.login(email, password)
.then(() => {

wixLocation.to( ‘/member/update/${wixUsers.currentUser.Email}’ );

});
}

1 Like

@aphrsmgmtsb Try this - >

let email;
$w.onReady( () => { 
 wixUsers.onLogin( (user) => {
        wixLocation.to('/member/update/${email}');
 });
}); 

exportfunction button142_click(event) {
  email = $w('#loginEmail').value;
  let password = $w('#loginPassword').value;
  wixUsers.login(email, password)
 }

https://www.wix.com/corvid/reference/wix-users/onlogin

@ajithkrr Also not working. I already set permission for everyone but still not working :frowning:

1 Like