-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60e5705
commit 2698f81
Showing
27 changed files
with
3,438 additions
and
2,028 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 |
---|---|---|
|
@@ -42,3 +42,6 @@ next-env.d.ts | |
|
||
# yarn | ||
.yarn | ||
|
||
# Sentry Config File | ||
.env.sentry-build-plugin |
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,47 @@ | ||
'use server' | ||
|
||
import { revalidatePath } from 'next/cache' | ||
import { redirect } from 'next/navigation' | ||
|
||
import { createClient } from '@/utils/supabase/server' | ||
|
||
export async function login(formData: FormData) { | ||
const supabase = createClient() | ||
|
||
// type-casting here for convenience | ||
// in practice, you should validate your inputs | ||
const data = { | ||
email: formData.get('email') as string, | ||
password: formData.get('password') as string, | ||
} | ||
|
||
const { error } = await supabase.auth.signInWithPassword(data) | ||
|
||
if (error) { | ||
return "error" | ||
// console.log(error) | ||
// redirect('/error') | ||
} | ||
revalidatePath('/', 'layout') | ||
redirect('/') | ||
} | ||
|
||
export async function signup(formData: FormData) { | ||
const supabase = createClient() | ||
|
||
// type-casting here for convenience | ||
// in practice, you should validate your inputs | ||
const data = { | ||
email: formData.get('email') as string, | ||
password: formData.get('password') as string, | ||
} | ||
|
||
const { error } = await supabase.auth.signUp(data) | ||
|
||
if (error) { | ||
redirect('/error') | ||
} | ||
|
||
revalidatePath('/', 'layout') | ||
redirect('/') | ||
} |
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,28 @@ | ||
import { type EmailOtpType } from '@supabase/supabase-js' | ||
import { type NextRequest } from 'next/server' | ||
|
||
import { createClient } from '@/utils/supabase/server' | ||
import { redirect } from 'next/navigation' | ||
|
||
export async function GET(request: NextRequest) { | ||
const { searchParams } = new URL(request.url) | ||
const token_hash = searchParams.get('token_hash') | ||
const type = searchParams.get('type') as EmailOtpType | null | ||
const next = searchParams.get('next') ?? '/' | ||
|
||
if (token_hash && type) { | ||
const supabase = createClient() | ||
|
||
const { error } = await supabase.auth.verifyOtp({ | ||
type, | ||
token_hash, | ||
}) | ||
if (!error) { | ||
// redirect user to specified redirect URL or root of app | ||
redirect(next) | ||
} | ||
} | ||
|
||
// redirect the user to an error page with some instructions | ||
redirect('/error') | ||
} |
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,30 @@ | ||
import { type EmailOtpType } from '@supabase/supabase-js' | ||
import { cookies } from 'next/headers' | ||
import { NextRequest, NextResponse } from 'next/server' | ||
// The client you created from the Server-Side Auth instructions | ||
import { createClient } from '@/utils/supabase/server' | ||
|
||
export async function GET(request: NextRequest) { | ||
const { searchParams } = new URL(request.url) | ||
const token_hash = searchParams.get('token_hash') | ||
const type = searchParams.get('type') as EmailOtpType | null | ||
const next = searchParams.get('next') ?? '/' | ||
const redirectTo = request.nextUrl.clone() | ||
redirectTo.pathname = next | ||
|
||
if (token_hash && type) { | ||
const supabase = createClient() | ||
|
||
const { error } = await supabase.auth.verifyOtp({ | ||
type, | ||
token_hash, | ||
}) | ||
if (!error) { | ||
return NextResponse.redirect(redirectTo) | ||
} | ||
} | ||
|
||
// return the user to an error page with some instructions | ||
redirectTo.pathname = '/auth/auth-code-error' | ||
return NextResponse.redirect(redirectTo) | ||
} |
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,23 @@ | ||
"use client"; | ||
|
||
import * as Sentry from "@sentry/nextjs"; | ||
import NextError from "next/error"; | ||
import { useEffect } from "react"; | ||
|
||
export default function GlobalError({ error }: { error: Error & { digest?: string } }) { | ||
useEffect(() => { | ||
Sentry.captureException(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html> | ||
<body> | ||
{/* `NextError` is the default Next.js error page component. Its type | ||
definition requires a `statusCode` prop. However, since the App Router | ||
does not expose status codes for errors, we simply pass 0 to render a | ||
generic error message. */} | ||
<NextError statusCode={0} /> | ||
</body> | ||
</html> | ||
); | ||
} |
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,4 @@ | ||
export { default as SignUp } from "./signUp" | ||
export { default as SignIn } from "./signIn" | ||
export { default as Forgot } from "./forgot" | ||
export { default as Reset } from "./reset" |
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
Oops, something went wrong.