fix: only redirect in layout only if on redirect page

This commit is contained in:
Rotimi Best
2025-09-10 17:18:01 +01:00
parent 12c0f00007
commit f60809a249
2 changed files with 3 additions and 13 deletions
@@ -112,7 +112,6 @@ export async function getProfile({
// Profile created, go to onboarding or lms // Profile created, go to onboarding or lms
if (!error && newProfileData) { if (!error && newProfileData) {
console.log('newProfileData', newProfileData);
user.update((_user) => ({ user.update((_user) => ({
..._user, ..._user,
fetchingUser: false, fetchingUser: false,
@@ -128,7 +127,6 @@ export async function getProfile({
handleLocaleChange(newProfileData[0].locale); handleLocaleChange(newProfileData[0].locale);
if (isOrgSite) { if (isOrgSite) {
console.log('isOrgSite', isOrgSite);
const { data, error } = await supabase const { data, error } = await supabase
.from('organizationmember') .from('organizationmember')
.insert({ .insert({
@@ -137,8 +135,6 @@ export async function getProfile({
role_id: 3 role_id: 3
}) })
.select(); .select();
console.log('data', data);
console.log('error', error);
if (error) { if (error) {
console.error('Error adding user to organisation', error); console.error('Error adding user to organisation', error);
} else { } else {
@@ -152,10 +148,8 @@ export async function getProfile({
} }
if (params.get('redirect')) { if (params.get('redirect')) {
console.log('redirect', params.get('redirect'));
goto(params.get('redirect') || ''); goto(params.get('redirect') || '');
} else { } else if (shouldRedirectOnAuth(path)) {
console.log('redirect', '/lms');
goto('/lms'); goto('/lms');
} }
return; return;
@@ -112,10 +112,6 @@
}); });
} }
$: console.log('data', data);
$: console.log('currentOrg', $currentOrg);
$: console.log('profile', $profile);
function setCurOrg(cOrg: CurrentOrg) { function setCurOrg(cOrg: CurrentOrg) {
if (!cOrg) return; if (!cOrg) return;
currentOrg.set(cOrg); currentOrg.set(cOrg);
@@ -136,7 +132,7 @@
{supabase} {supabase}
isLogin={false} isLogin={false}
{handleSubmit} {handleSubmit}
isLoading={loading} isLoading={loading || !$profile.id}
showOnlyContent={true} showOnlyContent={true}
showLogo={true} showLogo={true}
bind:formRef bind:formRef
@@ -151,7 +147,7 @@
label="Join Course" label="Join Course"
type="submit" type="submit"
isDisabled={disableSubmit || loading} isDisabled={disableSubmit || loading}
isLoading={loading} isLoading={loading || !$profile.id}
/> />
</div> </div>
</AuthUI> </AuthUI>