Skip to content
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

feat: migrate to v4 #40

Merged
merged 30 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
90cef24
chore: bump nextjs to 11
ndom91 Jun 20, 2021
a52af26
Merge branch 'main' of ssh://github.com/nextauthjs/next-auth-example
ndom91 Aug 11, 2021
47a4866
feat: migrate to v4.0.0-next.20
ndom91 Aug 11, 2021
f80a7d3
fix: config comments
ndom91 Aug 11, 2021
e3f304a
fix: add nodemailer as manual dependency
ndom91 Aug 11, 2021
f1af1e2
feat: add ndom91 as contributor :grin:
ndom91 Aug 11, 2021
6b09ce7
fix: provider import
ndom91 Aug 11, 2021
a56e9c9
feat: update next-auth
ndom91 Aug 27, 2021
005958b
fix: add package-lock
ndom91 Aug 27, 2021
039930e
feat: update next-auth to v4-beta.1
ndom91 Sep 5, 2021
06b7ac9
fix: remove carrot
ndom91 Sep 5, 2021
10cbc2a
feat: upgrade to beta.2
ndom91 Sep 7, 2021
f7d2d3b
fix: filename typo
ndom91 Oct 23, 2021
db89e51
feat: add Next.js 12 Middleware example page
balazsorban44 Oct 27, 2021
abecbb1
chore: simplify Middleware
balazsorban44 Oct 27, 2021
55d872a
chore: revert
balazsorban44 Oct 27, 2021
3ca025a
chore(deps): ugprade `next-auth`
balazsorban44 Oct 29, 2021
daf174f
chore: change url check
balazsorban44 Oct 29, 2021
23e4481
chore: add logs, refactor middleware
balazsorban44 Oct 29, 2021
2cfe764
fix: use new theme option
balazsorban44 Oct 29, 2021
35121e5
Image url value must be quoted within a string template (#46)
goo32 Nov 23, 2021
85e3e52
chore: remove lock file
balazsorban44 Nov 23, 2021
21d7a3e
Merge branch 'ndom91/update-v4' of github.com:nextauthjs/next-auth-ex…
balazsorban44 Nov 23, 2021
dc5ba10
chore: update [email protected]
ndom91 Nov 23, 2021
867d6b1
fix: exact version
ndom91 Nov 26, 2021
86373fa
Update _middleware.js
balazsorban44 Nov 30, 2021
2e3994c
fix: comment out email adapter
ndom91 Dec 1, 2021
7db6a67
feat: [email protected]
ndom91 Dec 1, 2021
f8ee115
fix: cleanup options
ndom91 Dec 1, 2021
3ff32ca
fix: rm sqlite3
ndom91 Dec 1, 2021
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
File renamed without changes.
2 changes: 1 addition & 1 deletion components/access-denied.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { signIn } from 'next-auth/client'
import { signIn } from 'next-auth/react'

export default function AccessDenied () {
return (
Expand Down
88 changes: 65 additions & 23 deletions components/header.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import Link from 'next/link'
import { signIn, signOut, useSession } from 'next-auth/client'
import styles from './header.module.css'
import Link from "next/link"
import { signIn, signOut, useSession } from "next-auth/react"
import styles from "./header.module.css"

// The approach used in this component shows how to built a sign in and sign out
// component that works on pages which support both client and server side
// rendering, and avoids any flash incorrect content on initial page load.
export default function Header () {
const [ session, loading ] = useSession()

export default function Header() {
const { data: session, status } = useSession()
const loading = status === "loading"

return (
<header>
<noscript>
<style>{`.nojs-show { opacity: 1; top: 0; }`}</style>
</noscript>
<div className={styles.signedInStatus}>
<p className={`nojs-show ${(!session && loading) ? styles.loading : styles.loaded}`}>
{!session && <>
<span className={styles.notSignedInText}>You are not signed in</span>
<a
<p
className={`nojs-show ${
!session && loading ? styles.loading : styles.loaded
}`}
>
{!session && (
<>
<span className={styles.notSignedInText}>
You are not signed in
</span>
<a
href={`/api/auth/signin`}
className={styles.buttonPrimary}
onClick={(e) => {
Expand All @@ -27,14 +35,22 @@ export default function Header () {
>
Sign in
</a>
</>}
{session && <>
{session.user.image && <span style={{backgroundImage: `url(${session.user.image})` }} className={styles.avatar}/>}
<span className={styles.signedInText}>
<small>Signed in as</small><br/>
<strong>{session.user.email || session.user.name}</strong>
</>
)}
{session && (
<>
{session.user.image && (
<span
style={{ backgroundImage: `url('${session.user.image}')` }}
className={styles.avatar}
/>
)}
<span className={styles.signedInText}>
<small>Signed in as</small>
<br />
<strong>{session.user.email || session.user.name}</strong>
</span>
<a
<a
href={`/api/auth/signout`}
className={styles.button}
onClick={(e) => {
Expand All @@ -44,16 +60,42 @@ export default function Header () {
>
Sign out
</a>
</>}
</>
)}
</p>
</div>
<nav>
<ul className={styles.navItems}>
<li className={styles.navItem}><Link href="/"><a>Home</a></Link></li>
<li className={styles.navItem}><Link href="/client"><a>Client</a></Link></li>
<li className={styles.navItem}><Link href="/server"><a>Server</a></Link></li>
<li className={styles.navItem}><Link href="/protected"><a>Protected</a></Link></li>
<li className={styles.navItem}><Link href="/api-example"><a>API</a></Link></li>
<li className={styles.navItem}>
<Link href="/">
<a>Home</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/client">
<a>Client</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/server">
<a>Server</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/protected">
<a>Protected</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/api-example">
<a>API</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/middleware-protected">
<a>Middleware protected</a>
</Link>
</li>
</ul>
</nav>
</header>
Expand Down
Loading