-
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.
Merge pull request #2 from walnuts1018/add-login
add
- Loading branch information
Showing
38 changed files
with
1,712 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig> | ||
<msapplication> | ||
<tile> | ||
<square70x70logo src="/favicons/mstile-70x70.png"/> | ||
<square150x150logo src="/favicons/mstile-150x150.png"/> | ||
<square310x310logo src="/favicons/mstile-310x310.png"/> | ||
<TileColor>#f9842c</TileColor> | ||
</tile> | ||
</msapplication> | ||
</browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,19 @@ | ||
{ | ||
"name": "", | ||
"short_name": "", | ||
"icons": [ | ||
{ | ||
"src": "/favicons/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/favicons/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#ffffff", | ||
"background_color": "#ffffff", | ||
"display": "standalone" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import { LoginButton, LogoutButton } from "./authbuttons"; | ||
export function Header() { | ||
return ( | ||
<> | ||
<header className="fixed top-0 z-50 w-full "> | ||
<div className="flex justify-center w-full h-20"> | ||
<div className="w-11/12 flex items-center justify-between text-black font-bold font-Nunito text-2xl px-1 space-x-1"> | ||
<div className="flex items-center"> | ||
<Image | ||
src="/logo.jpg" | ||
alt="logo" | ||
width={40} | ||
height={40} | ||
style={{ objectFit: "contain" }} | ||
className="min-w-[40px] max-w-[40px] mx-1" | ||
/> | ||
<Link className="logo" href="/"> | ||
OpenChokin | ||
</Link> | ||
</div> | ||
<div className="flex items-center space-x-2 font-Noto font-semibold text-xl"> | ||
<LoginButton /> | ||
<LogoutButton /> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="flex justify-center w-full bg-white border-0 "> | ||
<div className="w-11/12 h-[3px] bg-gray-200 px-20"></div> | ||
</div> | ||
</header> | ||
</> | ||
); | ||
} |
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,57 @@ | ||
import NextAuth from "next-auth"; | ||
import { JWT } from "next-auth/jwt"; | ||
import ZitadelProvider from "next-auth/providers/zitadel"; | ||
import { custom } from "openid-client"; | ||
|
||
custom.setHttpOptionsDefaults({ | ||
timeout: 10000, | ||
}); | ||
|
||
const authOptions = { | ||
providers: [ | ||
ZitadelProvider({ | ||
clientId: process.env.ZITADEL_CLIENT_ID as string, | ||
clientSecret: process.env.ZITADEL_CLIENT_SECRET as string, | ||
issuer: process.env.ZITADEL_URL, | ||
}), | ||
], | ||
callbacks: { | ||
jwt: async ({ | ||
token, | ||
user, | ||
account, | ||
profile, | ||
isNewUser, | ||
}: { | ||
token: JWT; | ||
user?: any; | ||
account?: any; | ||
profile?: any; | ||
isNewUser?: boolean; | ||
}) => { | ||
if (user) { | ||
token.user = user; | ||
const u = user as any; | ||
token.role = u.role; | ||
} | ||
if (account) { | ||
token.accessToken = account.access_token; | ||
} | ||
return token; | ||
}, | ||
session: ({ session, token }: { token: JWT; session?: any }) => { | ||
token.accessToken; | ||
return { | ||
...session, | ||
user: { | ||
...session.user, | ||
role: token.role, | ||
}, | ||
}; | ||
}, | ||
}, | ||
}; | ||
|
||
const handler = NextAuth(authOptions); | ||
|
||
export { handler as GET, handler as POST }; |
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,25 @@ | ||
"use client"; | ||
import { signIn, signOut } from "next-auth/react"; | ||
|
||
export const LoginButton = () => { | ||
return ( | ||
<button | ||
className="bg-[#f9842c] hover:bg-[#FA6C28] rounded-full text-white px-4 py-1 border-[#f9842c] border-2 hover:border-[#FA6C28] font-Noto font-semibold text-xl" | ||
style={{ marginRight: 10 }} | ||
onClick={() => signIn()} | ||
> | ||
ログイン | ||
</button> | ||
); | ||
}; | ||
|
||
export const LogoutButton = () => { | ||
return ( | ||
<button | ||
className="bg-white hover:bg-gray-100 rounded-full text-[#f9842c] px-4 py-1 border-[#f9842c] border-2 font-Noto font-semibold text-xl" | ||
onClick={() => signOut()} | ||
> | ||
ログアウト | ||
</button> | ||
); | ||
}; |
Binary file not shown.
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
Oops, something went wrong.