-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lego/feat/supabase auth #24
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2e8c4fe
feat(MobileNavbarItem): children with onClick can close menu adhoc
joseglego 90f54ab
feat(Nav): avoid new window for click on Logo / Home
joseglego 294c250
chore(Auth): include Supabase needs/packages/boilerplates
joseglego 22d85a8
feat(Login): define Page with Supabase auth
joseglego 074ca0b
feat(MainNav): move from Clerk to Supabase
joseglego ee5e723
feat(Nav): move from Clerk to Supabase Nav, MainNavbar & MobileNavbar
joseglego 4632bd5
chore(Auth): remove orphan Auth logic
joseglego ba66952
chore(Auth): remove Clerk
joseglego 6d9aab1
chore(GQL_API): auto update
joseglego b752bb0
chore(Linter): Removing file and fixing some small inter errors
fforres d01d801
Creating <AuthProvider /> (#26)
fforres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
NEXT_PUBLIC_JSCL_API_URL='https://api.jsconf.dev/graphql' | ||
NEXT_PUBLIC_TOKEN_STORAGE_KEY='HS:token_storage_key' | ||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY='pk_test_ZnVua3ktZ3JpZmZvbi04NC5jbGVyay5hY2NvdW50cy5kZXYk' | ||
NEXT_PUBLIC_GOOGLE_MAPS_KEY='your_google_maps_key_here' | ||
NEXT_PUBLIC_SUPABASE_URL='your_supabase_url' | ||
NEXT_PUBLIC_SUPABASE_ANON_KEY='your_supabase_key' |
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,93 @@ | ||
"use client"; | ||
|
||
import { NextPage } from "next"; | ||
|
||
import { redirect } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import { Session } from "@supabase/supabase-js"; | ||
import { Auth } from "@supabase/auth-ui-react"; | ||
import { ThemeSupa } from "@supabase/auth-ui-shared"; | ||
import { createClient } from "@/utils/supabase/client"; | ||
import { useTheme } from "next-themes"; | ||
|
||
const supabase = createClient(); | ||
|
||
const AuthPage: NextPage = () => { | ||
const [session, setSession] = useState<Session | null>(null); | ||
const { resolvedTheme } = useTheme(); | ||
const [url, setUrl] = useState<string | undefined>(); | ||
|
||
useEffect(() => { | ||
const url = new URL(window.location.href); | ||
url.pathname = "/"; | ||
url.hash = ""; | ||
setUrl(url.toString()); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
supabase.auth.getSession().then(async ({ data: { session } }) => { | ||
setSession(session); | ||
await supabase.auth.startAutoRefresh(); | ||
}); | ||
|
||
const { | ||
data: { subscription }, | ||
} = supabase.auth.onAuthStateChange(async (_event, session) => { | ||
await supabase.auth.startAutoRefresh(); | ||
setSession(session); | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}, []); | ||
|
||
if (session) { | ||
redirect("/"); | ||
} | ||
|
||
return ( | ||
<div className="min-h-[calc(100dvh-57px)] w-full bg-muted px-4 pt-8"> | ||
<div className="m-auto flex w-full max-w-lg shrink-0 flex-col gap-4 rounded-2xl bg-background p-10 shadow-xl"> | ||
<div> | ||
<h1 className="text-left text-2xl font-bold">Regístrate.</h1> | ||
<p className="text-left text-sm text-muted-foreground"> | ||
Mantente al tanto de las novedades de JavaScript Chile. | ||
</p> | ||
</div> | ||
|
||
<Auth | ||
providers={["github", "twitter"]} | ||
supabaseClient={supabase} | ||
socialLayout="horizontal" | ||
showLinks={false} | ||
view="magic_link" | ||
redirectTo={url} | ||
localization={{ | ||
variables: { | ||
magic_link: { | ||
email_input_label: "Correo electrónico", | ||
email_input_placeholder: "Ingresa tu correo electrónico", | ||
button_label: "Enviar enlace mágico ✨", | ||
confirmation_text: "Revisa tu correo electrónico", | ||
empty_email_address: "Debes ingresar un correo electrónico", | ||
loading_button_label: "Enviando...", | ||
}, | ||
}, | ||
}} | ||
appearance={{ | ||
theme: ThemeSupa, | ||
variables: { | ||
default: { | ||
colors: { | ||
brand: "#000", | ||
brandAccent: "#2a2a2a", | ||
}, | ||
}, | ||
}, | ||
}} | ||
theme={resolvedTheme} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AuthPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { type NextRequest } from 'next/server' | ||
import { updateSession } from '@/utils/supabase/middleware' | ||
|
||
export async function middleware(request: NextRequest) { | ||
return await updateSession(request) | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
/* | ||
* Match all request paths except for the ones starting with: | ||
* - _next/static (static files) | ||
* - _next/image (image optimization files) | ||
* - favicon.ico (favicon file) | ||
* Feel free to modify this pattern to include more paths. | ||
*/ | ||
'/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)', | ||
], | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pense q ibamos a redirigir a auth.jschile.org 🤔
O eso pa después?