generated from CSES-UCSD/nextjs-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
UCSD Google Authentication #3
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
Open
cadencheng888
wants to merge
1
commit into
main
Choose a base branch
from
feature/google-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
| node_modules/ | ||
| .next/ | ||
| .env.local | ||
| .DS_Store |
This file contains hidden or 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,2 @@ | ||
| import { handlers } from "../../../../auth"; | ||
| export const { GET, POST } = handlers; |
This file contains hidden or 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 @@ | ||
| export default function Page() { | ||
| return ( | ||
| <div> | ||
| <h1>LIMS Dashboard</h1> | ||
| <h1>Loggied in!</h1> | ||
| </div> | ||
|
|
||
| ) | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,34 +1,16 @@ | ||
| import type { Metadata } from "next"; | ||
| import localFont from "next/font/local"; | ||
| "use client" | ||
| import Link from 'next/link' | ||
| import { SessionProvider } from "next-auth/react" | ||
|
|
||
| export default function Layout({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <html> | ||
| <body> | ||
| <SessionProvider> | ||
|
|
||
| import "./globals.css"; | ||
|
|
||
| const geistSans = localFont({ | ||
| src: "./fonts/GeistVF.woff", | ||
| variable: "--font-geist-sans", | ||
| weight: "100 900", | ||
| }); | ||
| const geistMono = localFont({ | ||
| src: "./fonts/GeistMonoVF.woff", | ||
| variable: "--font-geist-mono", | ||
| weight: "100 900", | ||
| }); | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Create Next App", | ||
| description: "Generated by create next app", | ||
| }; | ||
|
|
||
| export default function RootLayout({ | ||
| children, | ||
| }: Readonly<{ | ||
| children: React.ReactNode; | ||
| }>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body className={`${geistSans.variable} ${geistMono.variable} antialiased`}> | ||
| {children} | ||
| </body> | ||
| </html> | ||
| ); | ||
| } | ||
| {children} | ||
| </SessionProvider> | ||
| </body> | ||
| </html> | ||
| ) | ||
| } |
This file contains hidden or 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,10 @@ | ||
| "use client" | ||
| import { signIn } from "next-auth/react"; | ||
|
|
||
| export default function LoginPage() { | ||
| return ( | ||
| <button onClick = {() => signIn("google", { callbackUrl: "/dashboard"})}> | ||
| Sign in with Google | ||
| </button> | ||
| ) | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,83 +1,12 @@ | ||
| import Image from "next/image"; | ||
| "use client" | ||
| import Link from 'next/link' | ||
| import { SessionProvider } from "next-auth/react" | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]"> | ||
| <main className="flex flex-col gap-8 row-start-2 items-center sm:items-start"> | ||
| <Image | ||
| className="dark:invert" | ||
| src="/next.svg" | ||
| alt="Next.js logo" | ||
| width={180} | ||
| height={38} | ||
| priority | ||
| /> | ||
| <ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]"> | ||
| <li className="mb-2"> | ||
| Get started by editing{" "} | ||
| <code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold"> | ||
| app/page.tsx | ||
| </code> | ||
| . | ||
| </li> | ||
| <li>Save and see your changes instantly.</li> | ||
| </ol> | ||
| export default function Page() { | ||
| return ( | ||
| <nav> | ||
| <Link href = "/login">Login </Link> | ||
| </nav> | ||
|
|
||
| <div className="flex gap-4 items-center flex-col sm:flex-row"> | ||
| <a | ||
| className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5" | ||
| href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <Image | ||
| className="dark:invert" | ||
| src="/vercel.svg" | ||
| alt="Vercel logomark" | ||
| width={20} | ||
| height={20} | ||
| /> | ||
| Deploy now | ||
| </a> | ||
| <a | ||
| className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44" | ||
| href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| Read our docs | ||
| </a> | ||
| </div> | ||
| </main> | ||
| <footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center"> | ||
| <a | ||
| className="flex items-center gap-2 hover:underline hover:underline-offset-4" | ||
| href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <Image aria-hidden src="/file.svg" alt="File icon" width={16} height={16} /> | ||
| Learn | ||
| </a> | ||
| <a | ||
| className="flex items-center gap-2 hover:underline hover:underline-offset-4" | ||
| href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <Image aria-hidden src="/window.svg" alt="Window icon" width={16} height={16} /> | ||
| Examples | ||
| </a> | ||
| <a | ||
| className="flex items-center gap-2 hover:underline hover:underline-offset-4" | ||
| href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <Image aria-hidden src="/globe.svg" alt="Globe icon" width={16} height={16} /> | ||
| Go to nextjs.org → | ||
| </a> | ||
| </footer> | ||
| </div> | ||
| ); | ||
| } | ||
| ) | ||
| } |
This file contains hidden or 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 @@ | ||
| import NextAuth from "next-auth"; | ||
| import GoogleProvider from "next-auth/providers/google"; | ||
|
|
||
| // How will we log users in, and how do we remember them? | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will either have to use UCSD SSO, or if that is not possible, create a user database & schema but for now Google sign in should work since they handle it. |
||
|
|
||
| export const { handlers, auth, signIn, signOut } = NextAuth({ | ||
| providers: [ | ||
| GoogleProvider({ | ||
| clientId: | ||
| process.env.GOOGLE_CLIENT_ID!, | ||
| clientSecret: | ||
| process.env.GOOGLE_CLIENT_SECRET!, | ||
| }), | ||
| ], | ||
| session: { | ||
| strategy: "jwt", | ||
| }, | ||
| secret: process.env.NEXTAUTH_SECRET, | ||
| }); | ||
This file contains hidden or 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,6 @@ | ||
| /// <reference types="next" /> | ||
| /// <reference types="next/image-types/global" /> | ||
| import "./.next/dev/types/routes.d.ts"; | ||
|
|
||
| // NOTE: This file should not be edited | ||
| // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need to commit and merge front-end changes since that will be done later, we can just commit the auth API changes to main