@brightweblabs/module-orgs 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/access.ts +4 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightweblabs/module-orgs",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
7
7
|
"files": [
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"@supabase/supabase-js": "^2.110.8",
|
|
26
26
|
"lucide-react": "^1.26.0",
|
|
27
27
|
"server-only": "^0.0.1",
|
|
28
|
-
"@brightweblabs/
|
|
29
|
-
"@brightweblabs/
|
|
28
|
+
"@brightweblabs/app-shell": "0.16.0",
|
|
29
|
+
"@brightweblabs/core-auth": "0.11.0",
|
|
30
30
|
"@brightweblabs/infra": "0.7.0",
|
|
31
|
-
"@brightweblabs/ui": "1.5.
|
|
31
|
+
"@brightweblabs/ui": "1.5.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^19.0.0",
|
package/src/access.ts
CHANGED
|
@@ -67,22 +67,13 @@ export function createOrganizationsStaffAccessGuard(
|
|
|
67
67
|
export function createOrganizationManageAccessGuard(
|
|
68
68
|
dependencies: OrganizationAccessDependencies,
|
|
69
69
|
) {
|
|
70
|
-
return async function organizationManageAccess(
|
|
70
|
+
return async function organizationManageAccess(_organizationId: string) {
|
|
71
71
|
const base = await resolveBaseOrganizationAccess(dependencies);
|
|
72
72
|
if (isAccessError(base)) return base;
|
|
73
|
-
if (base.role
|
|
74
|
-
return { ok:
|
|
73
|
+
if (base.role !== "admin" && base.role !== "staff") {
|
|
74
|
+
return { ok: false, status: 403, error: "Acesso proibido." } as const;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
const { data, error } = await base.serviceSupabase
|
|
78
|
-
.from("organization_members")
|
|
79
|
-
.select("role")
|
|
80
|
-
.eq("organization_id", organizationId)
|
|
81
|
-
.eq("profile_id", base.profileId)
|
|
82
|
-
.maybeSingle<{ role: string }>();
|
|
83
|
-
if (error) return { ok: false, status: 500, error: error.message } as const;
|
|
84
|
-
if (data?.role !== "admin") return { ok: false, status: 403, error: "Acesso proibido." } as const;
|
|
85
|
-
return { ok: true, ...base, isOrgMember: true, isOrgAdmin: true } as const;
|
|
76
|
+
return { ok: true, ...base } as const;
|
|
86
77
|
};
|
|
87
78
|
}
|
|
88
79
|
|