OnLogin code is not executed

Hello,
would you please help me with following problem: I have a page with Login button and I would like when user logs in - a code to be executed which checks if customer exist and if yes - to redirect it to a specific page , if customer is new - redirect him to another page.
Here is the code but it never gets executed - I am not redirected to neither page …:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
wixUsers.onLogin( (user) => {
user = wixUsers.currentUser;
user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com
wixData.query(“mydatabasewithusers”)
.eq(“contacts_userEmail”, userEmail)
.find()
.then( (results) => {
if(results.items.length <= 0 ) {
//redirect to New User creation
wixLocation.to(‘/NewUser’);
} else {
//redirect to existing user info Dashboard
wixLocation.to(‘/ExistingUsers/Dashboard’);
}

							}); 

					} ); 

});

Hi,

Can you describe where did you put it, and check whether there were errors in the console?

Thanks,
Idan.

Hello Idan,
I put the code into a page which has just a Login App and a text box.
I simplified the code on that page just to display the email of loggedin user to the following :
import wixUsers from ‘wix-users’;
wixUsers.onLogin((user) => {
let userEmail = wixUsers.currentUser.getEmail();
$w(“#text1”).text = userEmail;

But still nothing is shown in Text1 box when user logs in…
would you please advise what might be wrong or a working example of code to be executed when user logs in ?
Regards,
Vasil