-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Microsoft 365 authentication using NextAuth.js (#14)
Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
- Loading branch information
1 parent
7da65ce
commit f265a72
Showing
13 changed files
with
378 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Tell NextAuth what is our app's canonical URL | ||
NEXTAUTH_URL=http://localhost:3000 | ||
|
||
# Configure a secret key for encrypting session tokens | ||
NEXTAUTH_SECRET=dev |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
import { NextIntlClientProvider, useMessages } from "next-intl"; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
params: { | ||
locale: string; | ||
}; | ||
}; | ||
|
||
export default function AuthLayout({ | ||
children, | ||
params: { locale }, | ||
}: LayoutProps) { | ||
const messages = useMessages(); | ||
|
||
return ( | ||
<NextIntlClientProvider locale={locale} messages={messages}> | ||
{children} | ||
</NextIntlClientProvider> | ||
); | ||
} |
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,31 @@ | ||
"use client"; | ||
|
||
import { useSearchParams } from "next/navigation"; | ||
import { useTranslations } from "next-intl"; | ||
import { signIn } from "next-auth/react"; | ||
|
||
function SignInButton() { | ||
const t = useTranslations("Auth.SignIn"); | ||
|
||
const params = useSearchParams(); | ||
const error = params.get("error"); | ||
return ( | ||
<div className="m-auto gap-7 flex flex-col items-center justify-center mt-20"> | ||
<button | ||
onClick={() => { | ||
signIn("azure-ad"); | ||
}} | ||
> | ||
{t("buttonLabel")} | ||
</button> | ||
{error && | ||
(error === "Callback" ? ( | ||
<p>{t("callbackError")}</p> | ||
) : ( | ||
<p>{t("otherError")}</p> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default SignInButton; |
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,9 @@ | ||
import SignInButton from "./SignInButton"; | ||
|
||
export default function SignInPage() { | ||
return ( | ||
<div> | ||
<SignInButton /> | ||
</div> | ||
); | ||
} |
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.