mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-09 14:00:15 -04:00
Init files for authentication
This commit is contained in:
parent
23e7ee7b9f
commit
7dc5aca9ee
|
@ -27,9 +27,9 @@ export default function Page() {
|
||||||
</div>
|
</div>
|
||||||
<Callout>
|
<Callout>
|
||||||
Welcome! Below you will find a list of resources for the
|
Welcome! Below you will find a list of resources for the
|
||||||
Compass Center's trained advocates. These materials serve to
|
Compass Center's trained advocates. These materials
|
||||||
virtually provide a collection of advocacy, resource, and
|
serve to virtually provide a collection of advocacy,
|
||||||
hotline manuals and information.
|
resource, and hotline manuals and information.
|
||||||
<b>
|
<b>
|
||||||
{" "}
|
{" "}
|
||||||
If you are an advocate looking for the contact
|
If you are an advocate looking for the contact
|
||||||
|
|
8
compass/utils/supabase/client.ts
Normal file
8
compass/utils/supabase/client.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { createBrowserClient } from "@supabase/ssr";
|
||||||
|
|
||||||
|
export function createClient() {
|
||||||
|
return createBrowserClient(
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
||||||
|
);
|
||||||
|
}
|
60
compass/utils/supabase/middleware.ts
Normal file
60
compass/utils/supabase/middleware.ts
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
||||||
|
import { NextResponse, type NextRequest } from "next/server";
|
||||||
|
|
||||||
|
export async function updateSession(request: NextRequest) {
|
||||||
|
let response = NextResponse.next({
|
||||||
|
request: {
|
||||||
|
headers: request.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const supabase = createServerClient(
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||||
|
{
|
||||||
|
cookies: {
|
||||||
|
get(name: string) {
|
||||||
|
return request.cookies.get(name)?.value;
|
||||||
|
},
|
||||||
|
set(name: string, value: string, options: CookieOptions) {
|
||||||
|
request.cookies.set({
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
response = NextResponse.next({
|
||||||
|
request: {
|
||||||
|
headers: request.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
response.cookies.set({
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
remove(name: string, options: CookieOptions) {
|
||||||
|
request.cookies.set({
|
||||||
|
name,
|
||||||
|
value: "",
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
response = NextResponse.next({
|
||||||
|
request: {
|
||||||
|
headers: request.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
response.cookies.set({
|
||||||
|
name,
|
||||||
|
value: "",
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await supabase.auth.getUser();
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
36
compass/utils/supabase/server.ts
Normal file
36
compass/utils/supabase/server.ts
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
|
export function createClient() {
|
||||||
|
const cookieStore = cookies();
|
||||||
|
|
||||||
|
return createServerClient(
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||||
|
{
|
||||||
|
cookies: {
|
||||||
|
get(name: string) {
|
||||||
|
return cookieStore.get(name)?.value;
|
||||||
|
},
|
||||||
|
set(name: string, value: string, options: CookieOptions) {
|
||||||
|
try {
|
||||||
|
cookieStore.set({ name, value, ...options });
|
||||||
|
} catch (error) {
|
||||||
|
// The `set` method was called from a Server Component.
|
||||||
|
// This can be ignored if you have middleware refreshing
|
||||||
|
// user sessions.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remove(name: string, options: CookieOptions) {
|
||||||
|
try {
|
||||||
|
cookieStore.set({ name, value: "", ...options });
|
||||||
|
} catch (error) {
|
||||||
|
// The `delete` method was called from a Server Component.
|
||||||
|
// This can be ignored if you have middleware refreshing
|
||||||
|
// user sessions.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user