-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from pedrolivaresanchez/security/post-only-au…
…thenticated-users security: now only authenticated users can post
- Loading branch information
Showing
10 changed files
with
161 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Suspense, useEffect } from 'react'; | |
import Login from '../../components/auth/Login'; | ||
import { useRouter, useSearchParams } from 'next/navigation'; | ||
import { authService } from '@/lib/service'; | ||
import { AlertTriangle } from 'lucide-react'; | ||
|
||
export default function AUthPage() { | ||
return ( | ||
|
@@ -28,6 +29,20 @@ function Auth() { | |
|
||
return ( | ||
<section className="mx-6 lg:m-16"> | ||
<div className="bg-red-100 border-l-4 border-red-500 p-4 rounded mb-4"> | ||
<div className="flex items-start"> | ||
<AlertTriangle className="h-5 w-5 text-red-500 mt-0.5 mr-2" /> | ||
<div> | ||
<h2 className="text-red-800 font-bold"> | ||
POR MOTIVOS DE SEGURIDAD HEMOS DESHABILITADO LAS PUBLICACIONES ANONIMAS | ||
</h2> | ||
<p className="text-red-700 text-sm mt-1">Ahora debes registrarte para crear una publicacion.</p> | ||
<p className="text-red-900 text-sm mt-1 font-medium"> | ||
Por dificultades tecnicas, por favor escríbenos a [email protected] | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<Login onSuccessCallback={() => router.push(redirect)} redirectUrl={redirect} /> | ||
</section> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
'use client'; | ||
import OfferHelp from '@/components/OfferHelp'; | ||
import { supabase } from '@/lib/supabase/client'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export default function OfrecerAyuda() { | ||
return <OfferHelp />; | ||
const [session, setSession] = useState(null); | ||
|
||
useEffect(() => { | ||
supabase.auth.getSession().then(({ data: { session } }: any) => { | ||
setSession(session); | ||
}); | ||
}, []); | ||
|
||
return session ? ( | ||
<OfferHelp sessionProp={session} /> | ||
) : ( | ||
<div className="flex justify-center items-center min-h-screen"> | ||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"></div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
supabase/migrations/20241109054846_limit_post_to_authenticated_users.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
drop policy "Enable insert access" on "public"."help_requests"; | ||
|
||
drop policy "Enable insert for all users" on "public"."help_requests"; | ||
|
||
drop policy "Enable insert for anonymous users" on "public"."help_requests"; | ||
|
||
drop policy "Enable_update_for_users_based_on_email" on "public"."help_requests"; | ||
|
||
create policy "Enable insert access" | ||
on "public"."help_requests" | ||
as permissive | ||
for insert | ||
to authenticated | ||
with check (true); | ||
|
||
|
||
create policy "Enable insert for all users" | ||
on "public"."help_requests" | ||
as permissive | ||
for insert | ||
to authenticated | ||
with check (true); | ||
|
||
|
||
create policy "Enable insert for anonymous users" | ||
on "public"."help_requests" | ||
as permissive | ||
for insert | ||
to authenticated | ||
with check (true); | ||
|
||
|
||
create policy "Enable_update_for_users_based_on_email" | ||
on "public"."help_requests" | ||
as permissive | ||
for update | ||
to authenticated | ||
using (((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email()))); | ||
|
||
|
||
|