I’m using Google Sign In inside Login page.
And onClick of the Sign In button I’m executing this code
{{navigateTo('https://abcde.supabase.co/auth/v1/authorize',{provider:"google",
redirect_to:`https://app.appsmith.com/app/feedback-app-dev/${auth.getUserDashboardAndId()}`},'SAME_WINDOW')}}
Here, the user should be redirected based on the user’s role.
This is my getUserDashboardAndId function
getUserDashboardAndId: () => {
//getUserData is the API call made to supabse, which returns some data.
getUserData.run((user) => {
storeValue('email', user.email)
})
getEmployeeByEmail.run((user) => {
storeValue("loggedin_user", user[0]);
});
const role = appsmith.store.loggedin_user.role;
if (role === "Employee") {
return "employeedashboard-63d89abcb8b46679d190f4c8";
} else if (role === "Reviewer") {
return "reviewerdashboard-63e24e094fc63a0df6b867ae";
} else {
return "admindashboard-63d89abcb8b46679d190f4e5";
}
},
Error: On Signing In I’m getting TypeError: Cannot read properties of undefined (reading ‘role’)
Seems like the code is running first before login data gets stored inside Store.
redirect_to: https://app.appsmith.com/app/feedback-app-dev/${auth.getUserDashboardAndId()}
My only concern is to redirect this URL to the respective dashboards based on the user’s role.