mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: redirection logic
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import Consent from '$lib/components/consent.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { campaigns } from '$lib/stores/campaigns';
|
||||
|
||||
onMount(async () => {
|
||||
// handle sources
|
||||
@@ -75,6 +76,21 @@
|
||||
const pathname = $page.url.pathname;
|
||||
const user = $page.data.account as Models.User<Record<string, string>>;
|
||||
|
||||
const code = $page.url.searchParams.get('code');
|
||||
if (code) {
|
||||
try {
|
||||
const couponData = await sdk.forConsole.billing.getCoupon(code);
|
||||
if (couponData?.campaign && campaigns.has(couponData.campaign)) {
|
||||
if (user) {
|
||||
goto(`${base}/console/apply-credit?code=${code}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRedirect(pathname, authenticationRoutes)) {
|
||||
if (user?.$id) {
|
||||
if (shouldRedirect(pathname, acceptedAuthenticatedRoutes)) {
|
||||
|
||||
Reference in New Issue
Block a user