feat: add Auth0 passwordless login
This commit is contained in:
3
app/api/auth/[auth0]/route.ts
Normal file
3
app/api/auth/[auth0]/route.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { handleAuth } from '@auth0/nextjs-auth0';
|
||||
|
||||
export const GET = handleAuth();
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UserProvider } from '@auth0/nextjs-auth0/client';
|
||||
import type { Metadata } from 'next';
|
||||
import { Inter } from 'next/font/google';
|
||||
import './globals.css';
|
||||
@@ -16,7 +17,9 @@ export default function RootLayout({
|
||||
}>) {
|
||||
return (
|
||||
<html lang='en'>
|
||||
<body className={inter.className}>{children}</body>
|
||||
<UserProvider>
|
||||
<body className={inter.className}>{children}</body>
|
||||
</UserProvider>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
8
app/login/page.tsx
Normal file
8
app/login/page.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function SignIn() {
|
||||
return (
|
||||
<div>
|
||||
<a href='/api/auth/login'>Login</a>
|
||||
<a href='/api/auth/logout'>Logout</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
18
app/user/page.tsx
Normal file
18
app/user/page.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import { useUser } from '@auth0/nextjs-auth0/client';
|
||||
|
||||
export default function ProfileClient() {
|
||||
const { user, error, isLoading } = useUser();
|
||||
|
||||
if (isLoading) return <div>Loading...</div>;
|
||||
if (error) return <div>{error.message}</div>;
|
||||
|
||||
return (
|
||||
user && (
|
||||
<div>
|
||||
<p>{user.email}</p>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user