mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix redirects
This commit is contained in:
@@ -41,7 +41,6 @@ export const canWriteTopics = derived(scopes, ($scopes) => $scopes.includes('top
|
||||
|
||||
export const canSeeBilling = derived(scopes, ($scopes) => $scopes.includes('billing.read'));
|
||||
export const canSeeProjects = derived(scopes, function ($scopes) {
|
||||
console.log($scopes);
|
||||
return $scopes.includes('projects.read');
|
||||
});
|
||||
export const canSeeDatabases = derived(scopes, ($scopes) => $scopes.includes('databases.read'));
|
||||
|
||||
@@ -4,17 +4,14 @@ import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { canSeeProjects } from '$lib/stores/roles';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export const load: PageLoad = async ({ params, url, route, depends, parent }) => {
|
||||
await parent();
|
||||
const {roles, scopes} = await parent();
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
const page = getPage(url);
|
||||
const limit = getLimit(url, route, CARD_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
|
||||
if (!get(canSeeProjects)) {
|
||||
if (!scopes.includes('projects.read') && scopes.includes('billing.read')) {
|
||||
return redirect(301, `/console/organization-${params.organization}/billing`);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@ import { Dependencies } from '$lib/constants';
|
||||
import type { Address } from '$lib/sdk/billing';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent, depends }) => {
|
||||
const { organization } = await parent();
|
||||
const { organization, scopes } = await parent();
|
||||
|
||||
if(!scopes.includes('billing.read')) {
|
||||
return redirect(301, `/console/organization-${organization.$id}`);
|
||||
}
|
||||
depends(Dependencies.PAYMENT_METHODS);
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
depends(Dependencies.CREDIT);
|
||||
|
||||
Reference in New Issue
Block a user