Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
440a8a9
Update hero.tsx
biomassives Nov 11, 2024
a168d90
Update site.ts
biomassives Nov 11, 2024
2fadcf9
Update site-logo.tsx
biomassives Nov 11, 2024
67a215c
new
biomassives Nov 12, 2024
1faa7d1
test deployment
biomassives Nov 12, 2024
99c4d72
test deployment
biomassives Nov 12, 2024
d655644
test deployment
biomassives Nov 12, 2024
e9379d8
test deployment
biomassives Nov 12, 2024
2c5bb14
test deployment
biomassives Nov 12, 2024
9d18650
ui error o fix
biomassives Nov 12, 2024
5b8ff7d
ui error o fix
biomassives Nov 12, 2024
071b8b5
ui error o fix
biomassives Nov 12, 2024
81cc326
ui error o fix
biomassives Nov 12, 2024
6af3eb0
ui error o fix
biomassives Nov 12, 2024
78dbd6f
ui error o fix
biomassives Nov 12, 2024
312438e
ui error o fix
biomassives Nov 12, 2024
dd51034
ui error o fix
biomassives Nov 12, 2024
d347da7
ui error o fix
biomassives Nov 12, 2024
7103390
auth-test page x
biomassives Nov 12, 2024
12d42cf
auth testing
biomassives Nov 12, 2024
753abc9
auth testing
biomassives Nov 12, 2024
0f39155
ui error o fix
biomassives Nov 12, 2024
fd4613a
ui error o fix
biomassives Nov 12, 2024
eb20566
ui error o fix
biomassives Nov 12, 2024
0f97ecb
ui error o fix
biomassives Nov 12, 2024
f3e9d06
ui error o fix
biomassives Nov 12, 2024
6ff8f90
ui error o fix
biomassives Nov 12, 2024
99d8459
ui error o fix
biomassives Nov 12, 2024
617f6cc
ui error o fix
biomassives Nov 12, 2024
7bafba8
ui error o fix
biomassives Nov 12, 2024
e0f1bd0
ui error o fix
biomassives Nov 12, 2024
5d5a79f
ui error o fix
biomassives Nov 12, 2024
e36b8f8
ui error o fix
biomassives Nov 12, 2024
1fb038e
ui error o fix
biomassives Nov 12, 2024
60da639
ui error o fix
biomassives Nov 12, 2024
8279c24
ui error o fix
biomassives Nov 12, 2024
b08dda4
ui error o fix
biomassives Nov 12, 2024
1e86e7c
ui error o fix
biomassives Nov 12, 2024
4dfda91
ui error o fix
biomassives Nov 13, 2024
40248cb
ui error o fix
biomassives Nov 13, 2024
e26be68
ui error o fix
biomassives Nov 13, 2024
a6d5cbf
ui error o fix
biomassives Nov 13, 2024
4916c45
ui error o fix
biomassives Nov 13, 2024
7c05a75
ui error o fix
biomassives Nov 13, 2024
1c53bdb
ui error o fix
biomassives Nov 13, 2024
6586c3e
ui error o fix
biomassives Nov 13, 2024
f326692
ui error o fix
biomassives Nov 13, 2024
b0d2334
ui error o fix
biomassives Nov 13, 2024
b27765f
ui error o fix
biomassives Nov 13, 2024
72662e3
ui error o fix
biomassives Nov 13, 2024
f73fe6b
ui error o fix
biomassives Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.env
/node_modules
Binary file added .notes..swp
Binary file not shown.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workbench.colorTheme": "G Dark (Haiti)"
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NextJS Supabase Dashboard
########## Appovideo Libay Manager Tool
## via NextJS Supabase Dashboard

This is a dashboard starter template for the [NextJS](https://nextjs.org) 14 app router using supabase based on [shadcn-ui](https://ui.shadcn.com).

Expand Down
50 changes: 15 additions & 35 deletions app/api/auth/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
// @/app/api/auth/callback/route.ts
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
import { type CookieOptions, createServerClient } from '@supabase/ssr'

/**
* OAuth with PKCE flow for SSR
*
* @link https://supabase.com/docs/guides/auth/server-side/oauth-with-pkce-flow-for-ssr
*/
export async function GET(request: Request) {
const { searchParams, origin } = new URL(request.url)
const code = searchParams.get('code')
// if "next" is in param, use it as the redirect URL
const next = searchParams.get('next') ?? '/'
const requestUrl = new URL(request.url)
const code = requestUrl.searchParams.get('code')
const next = requestUrl.searchParams.get('next') || '/dashboard'

if (code) {
const cookieStore = cookies()
const supabase = 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) {
cookieStore.set({ name, value, ...options })
},
remove(name: string, options: CookieOptions) {
cookieStore.delete({ name, ...options })
},
},
}
)

const supabase = createRouteHandlerClient({ cookies })
const { error } = await supabase.auth.exchangeCodeForSession(code)

if (!error) {
return NextResponse.redirect(`${origin}${next}`)

if (error) {
console.error('Auth callback error:', error)
return NextResponse.redirect(
new URL('/auth/signin?error=' + encodeURIComponent(error.message), request.url)
)
}
}

// return the user to an error page with instructions
return NextResponse.redirect(`${origin}/auth/auth-code-error`)
}
// Redirect to the dashboard or specified next page
return NextResponse.redirect(new URL(next, request.url))
}
32 changes: 17 additions & 15 deletions app/api/auth/confirm/route.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// app/api/auth/confirm/route.ts
import { createServerClient, type CookieOptions } from '@supabase/ssr'
import { type EmailOtpType } from '@supabase/supabase-js'
import { cookies } from 'next/headers'
import { NextResponse, type NextRequest } from 'next/server'

/**
* Email Auth with PKCE flow for SSR
*
* @link https://supabase.com/docs/guides/auth/server-side/email-based-auth-with-pkce-flow-for-ssr
*/
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const token_hash = searchParams.get('token_hash') as string
export async function GET(request: NextRequest)
{
try {
const { searchParams, origin } = new URL(request.url) // Define origin here
const token_hash = searchParams.get('token_hash')
const type = searchParams.get('type') as EmailOtpType | null
// if "next" is in param, use it as the redirect URL
const next = (searchParams.get('next') as string) ?? '/'
const redirectTo = request.nextUrl.clone()
redirectTo.pathname = next

if (token_hash && type) {
if (!token_hash || !type) {
throw new Error('Missing token_hash or type')
}
const cookieStore = cookies()
const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
Expand All @@ -39,12 +39,14 @@ export async function GET(request: NextRequest) {

const { error } = await supabase.auth.verifyOtp({ type, token_hash })

if (!error) {
return NextResponse.redirect(redirectTo)
if (error) {
throw error // Re-throw the error to be caught by the catch block
}
}

// return the user to an error page with some instructions
redirectTo.pathname = '/auth/auth-code-error'
return NextResponse.redirect(redirectTo)
return NextResponse.redirect(redirectTo)
} catch (error) {
console.error('Error in /auth/confirm:', error)
const redirectTo = new URL('/auth/auth-code-error', request.nextUrl.origin)
return NextResponse.redirect(redirectTo)
}
}
12 changes: 12 additions & 0 deletions app/auth-test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

// @/app/auth-test/page.tsx
import AuthTest from '@/components/auth-test'

export default function TestPage() {
return (
<div className="container mx-auto py-8">
<h1 className="text-2xl font-bold mb-4">Auth Test Page</h1>
<AuthTest />
</div>
)
}
48 changes: 48 additions & 0 deletions app/auth/callback/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// app/auth/callback/page.tsx
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'

export const dynamic = 'force-dynamic'

export default async function AuthCallbackPage({
searchParams,
}: {
searchParams: { code: string; next?: string }
}) {
const cookieStore = cookies()
const supabase = 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: any) {
cookieStore.set({ name, value, ...options })
},
remove(name: string, options: any) {
cookieStore.delete({ name, ...options })
},
},
}
)

const code = searchParams.code

try {
if (code) {
const { error } = await supabase.auth.exchangeCodeForSession(code)
if (error) {
throw error
}
}

// URL to redirect to after sign in process completes
return redirect(searchParams.next || '/dashboard')
} catch (error) {
console.error('Auth callback error:', error)
return redirect('/auth/auth-code-error')
}
}
32 changes: 32 additions & 0 deletions app/auth/signin/signin-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,44 @@ const SignInForm = () => {
defaultValues,
})


// Add dev login function
const handleDevLogin = async () => {
const supabase = createClient()
try {
const { data, error } = await supabase.auth.signInWithPassword({
email: 'dev@approvideo.org', // Replace with your dev email
password: 'devpass123' // Replace with your dev password
})

if (error) throw error

toast.success('Dev login successful')
window.location.href = '/dashboard' // Force reload to ensure auth state
} catch (error) {
console.error('Dev login failed:', error)
toast.error('Dev login failed')
}
}


return (
<Form {...form}>
<form method="POST" noValidate className="space-y-4">
<EmailField />
<PasswordField />
<SubmitButton />

<Button
type="button"
variant="secondary"
onClick={handleDevLogin}
className="w-full mt-2"
>
Dev Login
</Button>


</form>
</Form>
)
Expand Down
Loading