How to go to different dashboards of different role users using the same login page? Given the registration page code and the login page code:

How to go to different dashboards of different role users using the same login page?

Given the registration page code and the login page code:

 

 

Registration page:

 

 

import wixUsers from 'wix-users';

 

import {assignRole} from 'backend/role';

let dropdownValue;

 

$w.onReady(function () {

$w("#dropdown1").onChange((event) => {

dropdownValue = event. target. value;

});

});

 

$w.onReady(function(){

$w('#register'). onClick(function (){

 

if (dropdownValue==1)

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

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

let first = $w("#fname"). value;

let last = $w("#lastName"). value;

 

 

wixUsers.register(email, password, {

contactInfo: {

"firstName": first,

"lastName": last

}

})

 

.then((results) => {

let roleId="e0eb1ac9-0107-4d3a-b247-e9fa80b62387";

assignRole(roleId, results. user. id);

}

);

 

} else {

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

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

let first = $w("#fname"). value;

let last = $w("#lastName"). value;

 

 

wixUsers.register(email, password, {

contactInfo: {

"firstName": first,

"lastName": last

}

})

 

.then((results) => {

let roleId="d990f333-d091-4670-ad29-f3a6d5e88f3f";

assignRole(roleId, results. user. id);

}

);

 

}

 

})})

 

 

Login page:

 

 

import wixUsers from 'wix-users';

import wixLocation from 'wix-location';

 

$w.onReady(function(){

$w('#loginNow').onClick(function (){

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

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

wixUsers. login(email,password)

.then(()=>{

wixLocation. to('/dashboard2');

})

})

})