Skip to content

Commit

Permalink
fixup pr
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes committed Oct 16, 2024
1 parent 41396d7 commit ce04819
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 174 deletions.
10 changes: 0 additions & 10 deletions src/app/(dynamic-pages)/(authenticated-pages)/onboarding/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Suspense } from 'react';
import { UserOnboardingFlow } from "./OnboardingFlow";

async function getDefaultOrganizationOrSet(): Promise<string | null> {
console.log(`get default organisation`)
const [slimOrganizations, defaultOrganizationId] = await Promise.all([
fetchSlimOrganizations(),
getDefaultOrganization(),
Expand All @@ -30,8 +29,6 @@ async function getDefaultOrganizationOrSet(): Promise<string | null> {
// reason, because of an invite or for some other reason,
// make sure that the default organization is set to the first
await setDefaultOrganization(firstOrganization.id);
console.log('set default organization to firstOrganization on onboarding', firstOrganization.id);

return firstOrganization.id;
}

Expand All @@ -41,26 +38,19 @@ async function getOnboardingConditions(userId: string) {
getUserProfile(userId),
getDefaultOrganizationOrSet(),
]);

console.log('userProfile on onboarding', userProfile);
console.log('defaultOrganizationId on onboarding', defaultOrganizationId);
return {
userProfile,
defaultOrganizationId,
};
}

async function OnboardingFlowWrapper({ userId, userEmail }: { userId: string; userEmail: string | undefined }) {
console.log(`onboarding flow wrapper ${userId} ${userEmail}`)
const [onboardingConditions, user] = await Promise.all([
getOnboardingConditions(userId),
serverGetLoggedInUser(),
]);
const { userProfile } = onboardingConditions;
console.log("userProfile", userProfile);
const onboardingStatus = authUserMetadataSchema.parse(user.user_metadata);
console.log(onboardingStatus);
console.log(userEmail);

return (
<UserOnboardingFlow
Expand Down
1 change: 0 additions & 1 deletion src/data/user/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const createDefaultUserPrivateInfo = async (userId: string) => {


export const getUserProfile = async (userId: string) => {
console.log(`get user profile ${userId}`)
const supabase = createSupabaseUserServerComponentClient();
const { data, error } = await supabase
.from("user_profiles")
Expand Down
298 changes: 149 additions & 149 deletions supabase/migrations/20230116105935_storage.sql
Original file line number Diff line number Diff line change
@@ -1,149 +1,149 @@
-- -- Create buckets
-- INSERT INTO STORAGE.buckets (id, name)
-- VALUES ('project-assets', 'project-assets') ON CONFLICT DO NOTHING;

-- INSERT INTO STORAGE.buckets (id, name)
-- VALUES ('user-assets', 'user-assets') ON CONFLICT DO NOTHING;

-- INSERT INTO STORAGE.buckets (id, name, public)
-- VALUES ('public-user-assets', 'public-user-assets', TRUE) ON CONFLICT DO NOTHING;

-- INSERT INTO STORAGE.buckets (id, name, public)
-- VALUES ('public-assets', 'public-assets', TRUE) ON CONFLICT DO NOTHING;

-- -- admin blog bucket
-- INSERT INTO STORAGE.buckets (id, name, public)
-- VALUES ('admin-blog', 'admin-blog', TRUE) ON CONFLICT DO NOTHING;

-- -- Create policies
-- DROP policy IF EXISTS "Give users access to own folder 10fq7k5_0" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 10fq7k5_0" ON "storage"."objects" AS permissive FOR
-- SELECT TO authenticated USING (
-- (
-- (bucket_id = 'user-assets'::text)
-- AND (
-- (
-- (
-- SELECT (
-- SELECT auth.uid()
-- )
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 10fq7k5_1" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 10fq7k5_1" ON "storage"."objects" AS permissive FOR
-- INSERT TO authenticated WITH CHECK (
-- (
-- (bucket_id = 'user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 10fq7k5_2" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 10fq7k5_2" ON "storage"."objects" AS permissive FOR
-- UPDATE TO authenticated USING (
-- (
-- (bucket_id = 'user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 10fq7k5_3" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 10fq7k5_3" ON "storage"."objects" AS permissive FOR DELETE TO authenticated USING (
-- (
-- (bucket_id = 'user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 1plzjhd_0" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 1plzjhd_0" ON "storage"."objects" AS permissive FOR
-- SELECT TO public USING (((bucket_id = 'public-user-assets'::text)));

-- DROP policy IF EXISTS "Give users access to own folder 1plzjhd_1" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 1plzjhd_1" ON "storage"."objects" AS permissive FOR
-- INSERT TO public WITH CHECK (
-- (
-- (bucket_id = 'public-user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 1plzjhd_2" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 1plzjhd_2" ON "storage"."objects" AS permissive FOR
-- UPDATE TO public USING (
-- (
-- (bucket_id = 'public-user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "Give users access to own folder 1plzjhd_3" ON "storage"."objects";
-- CREATE policy "Give users access to own folder 1plzjhd_3" ON "storage"."objects" AS permissive FOR DELETE TO public USING (
-- (
-- (bucket_id = 'public-user-assets'::text)
-- AND (
-- (
-- (
-- SELECT auth.uid()
-- )
-- )::text = (STORAGE.foldername(name)) [1]
-- )
-- )
-- );

-- DROP policy IF EXISTS "anything 1plzjhd_0" ON "storage"."objects";
-- CREATE policy "anything 1plzjhd_0" ON "storage"."objects" AS permissive FOR
-- UPDATE TO public USING (TRUE);

-- DROP policy IF EXISTS "anything 1plzjhd_1" ON "storage"."objects";
-- CREATE policy "anything 1plzjhd_1" ON "storage"."objects" AS permissive FOR
-- SELECT TO public USING (TRUE);

-- DROP policy IF EXISTS "anything 1plzjhd_2" ON "storage"."objects";
-- CREATE policy "anything 1plzjhd_2" ON "storage"."objects" AS permissive FOR DELETE TO public USING (TRUE);

-- DROP policy IF EXISTS "Public Access for public-assets 1plzjha_3" ON "storage"."objects";
-- CREATE policy "Public Access for public-assets 1plzjha_3" ON STORAGE.objects FOR
-- SELECT USING (bucket_id = 'public-assets');

-- -- anyone can view assets in admin-blog
-- DROP policy IF EXISTS "Public Access for admin-blog" ON "storage"."objects";
-- CREATE policy "Public Access for admin-blog " ON STORAGE.objects FOR
-- SELECT USING (bucket_id = 'admin-blog');

-- INSERT INTO app_settings (id)
-- VALUES (1) ON CONFLICT DO NOTHING;
-- Create buckets
INSERT INTO STORAGE.buckets (id, name)
VALUES ('project-assets', 'project-assets') ON CONFLICT DO NOTHING;

INSERT INTO STORAGE.buckets (id, name)
VALUES ('user-assets', 'user-assets') ON CONFLICT DO NOTHING;

INSERT INTO STORAGE.buckets (id, name, public)
VALUES ('public-user-assets', 'public-user-assets', TRUE) ON CONFLICT DO NOTHING;

INSERT INTO STORAGE.buckets (id, name, public)
VALUES ('public-assets', 'public-assets', TRUE) ON CONFLICT DO NOTHING;

-- admin blog bucket
INSERT INTO STORAGE.buckets (id, name, public)
VALUES ('admin-blog', 'admin-blog', TRUE) ON CONFLICT DO NOTHING;

-- Create policies
DROP policy IF EXISTS "Give users access to own folder 10fq7k5_0" ON "storage"."objects";
CREATE policy "Give users access to own folder 10fq7k5_0" ON "storage"."objects" AS permissive FOR
SELECT TO authenticated USING (
(
(bucket_id = 'user-assets'::text)
AND (
(
(
SELECT (
SELECT auth.uid()
)
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 10fq7k5_1" ON "storage"."objects";
CREATE policy "Give users access to own folder 10fq7k5_1" ON "storage"."objects" AS permissive FOR
INSERT TO authenticated WITH CHECK (
(
(bucket_id = 'user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 10fq7k5_2" ON "storage"."objects";
CREATE policy "Give users access to own folder 10fq7k5_2" ON "storage"."objects" AS permissive FOR
UPDATE TO authenticated USING (
(
(bucket_id = 'user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 10fq7k5_3" ON "storage"."objects";
CREATE policy "Give users access to own folder 10fq7k5_3" ON "storage"."objects" AS permissive FOR DELETE TO authenticated USING (
(
(bucket_id = 'user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 1plzjhd_0" ON "storage"."objects";
CREATE policy "Give users access to own folder 1plzjhd_0" ON "storage"."objects" AS permissive FOR
SELECT TO public USING (((bucket_id = 'public-user-assets'::text)));

DROP policy IF EXISTS "Give users access to own folder 1plzjhd_1" ON "storage"."objects";
CREATE policy "Give users access to own folder 1plzjhd_1" ON "storage"."objects" AS permissive FOR
INSERT TO public WITH CHECK (
(
(bucket_id = 'public-user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 1plzjhd_2" ON "storage"."objects";
CREATE policy "Give users access to own folder 1plzjhd_2" ON "storage"."objects" AS permissive FOR
UPDATE TO public USING (
(
(bucket_id = 'public-user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "Give users access to own folder 1plzjhd_3" ON "storage"."objects";
CREATE policy "Give users access to own folder 1plzjhd_3" ON "storage"."objects" AS permissive FOR DELETE TO public USING (
(
(bucket_id = 'public-user-assets'::text)
AND (
(
(
SELECT auth.uid()
)
)::text = (STORAGE.foldername(name)) [1]
)
)
);

DROP policy IF EXISTS "anything 1plzjhd_0" ON "storage"."objects";
CREATE policy "anything 1plzjhd_0" ON "storage"."objects" AS permissive FOR
UPDATE TO public USING (TRUE);

DROP policy IF EXISTS "anything 1plzjhd_1" ON "storage"."objects";
CREATE policy "anything 1plzjhd_1" ON "storage"."objects" AS permissive FOR
SELECT TO public USING (TRUE);

DROP policy IF EXISTS "anything 1plzjhd_2" ON "storage"."objects";
CREATE policy "anything 1plzjhd_2" ON "storage"."objects" AS permissive FOR DELETE TO public USING (TRUE);

DROP policy IF EXISTS "Public Access for public-assets 1plzjha_3" ON "storage"."objects";
CREATE policy "Public Access for public-assets 1plzjha_3" ON STORAGE.objects FOR
SELECT USING (bucket_id = 'public-assets');

-- anyone can view assets in admin-blog
DROP policy IF EXISTS "Public Access for admin-blog" ON "storage"."objects";
CREATE policy "Public Access for admin-blog " ON STORAGE.objects FOR
SELECT USING (bucket_id = 'admin-blog');

INSERT INTO app_settings (id)
VALUES (1) ON CONFLICT DO NOTHING;
14 changes: 7 additions & 7 deletions supabase/migrations/20240423143011_changelogs_storage_bucket.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- insert into storage.buckets(id, name, public, file_size_limit) values ('changelog-assets', 'changelog-assets', true, 52428800);
insert into storage.buckets(id, name, public, file_size_limit) values ('changelog-assets', 'changelog-assets', true, 52428800);

-- create policy "Allow users to read their changelog assets"
-- on "storage"."objects"
-- as permissive
-- for select
-- to public
-- using ((bucket_id = 'changelog-assets'::text));
create policy "Allow users to read their changelog assets"
on "storage"."objects"
as permissive
for select
to public
using ((bucket_id = 'changelog-assets'::text));


14 changes: 7 additions & 7 deletions supabase/migrations/20240522201153_openai_images_bucket.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- insert into storage.buckets(id, name, public, file_size_limit) values ('openai-images', 'openai-images', true, 52428800);
insert into storage.buckets(id, name, public, file_size_limit) values ('openai-images', 'openai-images', true, 52428800);

-- create policy "Allow users to read their openai images"
-- on "storage"."objects"
-- as permissive
-- for select
-- to public
-- using ((bucket_id = 'openai-images'::text));
create policy "Allow users to read their openai images"
on "storage"."objects"
as permissive
for select
to public
using ((bucket_id = 'openai-images'::text));


0 comments on commit ce04819

Please sign in to comment.