mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fetch roles and store
This commit is contained in:
1 parent
bdcbf841fc
commit
903f721bcd
2 files changed
+25
No files matched your search
@@ -272,6 +272,11 @@ export type PlansInfo = {
|
||||
|
||||
export type PlansMap = Map<Tier, Plan>;
|
||||
|
||||
export type Roles = {
|
||||
scopes: string[],
|
||||
roles: string[],
|
||||
}
|
||||
|
||||
export class Billing {
|
||||
client: Client;
|
||||
|
||||
@@ -353,6 +358,18 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async getScopes(organizationId: string): Promise<Roles> {
|
||||
const path = `/organizations/${organizationId}/roles`;
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
'get',
|
||||
uri,
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async updatePlan(
|
||||
organizationId: string,
|
||||
billingPlan: string,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { page } from "$app/stores";
|
||||
import { derived } from "svelte/store";
|
||||
|
||||
export const roles = derived(page, ($page) => $page.data.roles);
|
||||
export const scopes = derived(page, ($page) => $page.data.scopes);
|
||||
export const isDeveloper = derived(roles, ($roles) => $roles.includes("developer"));
|
||||
|
||||
export const canSeeDatabases = derived(scopes, ($scopes) => $scopes.includes("databases.read"));
|
||||
Reference in new issue
Block a user