-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a3adce
commit 96f51ec
Showing
13 changed files
with
351 additions
and
159 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
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
74 changes: 74 additions & 0 deletions
74
packages/app/prisma/migrations/20231005010012_replace_auth0_with_next_auth/migration.sql
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,74 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `auth0Data` on the `User` table. All the data in the column will be lost. | ||
- You are about to drop the column `auth0Sid` on the `User` table. All the data in the column will be lost. | ||
- A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- DropIndex | ||
DROP INDEX "User_auth0Sid_key"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" DROP COLUMN "auth0Data", | ||
DROP COLUMN "auth0Sid", | ||
ADD COLUMN "emailVerified" TIMESTAMP(3), | ||
ADD COLUMN "image" TEXT, | ||
ADD COLUMN "name" TEXT, | ||
ALTER COLUMN "email" DROP NOT NULL; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Account" ( | ||
"id" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"type" TEXT NOT NULL, | ||
"provider" TEXT NOT NULL, | ||
"providerAccountId" TEXT NOT NULL, | ||
"refresh_token" TEXT, | ||
"access_token" TEXT, | ||
"expires_at" INTEGER, | ||
"token_type" TEXT, | ||
"scope" TEXT, | ||
"id_token" TEXT, | ||
"session_state" TEXT, | ||
|
||
CONSTRAINT "Account_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Session" ( | ||
"id" TEXT NOT NULL, | ||
"sessionToken" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"expires" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "Session_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "VerificationToken" ( | ||
"identifier" TEXT NOT NULL, | ||
"token" TEXT NOT NULL, | ||
"expires" TIMESTAMP(3) NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import React from 'react' | ||
import {UserProvider} from '@auth0/nextjs-auth0/client' | ||
import {SessionProvider} from 'next-auth/react' | ||
import type {AppProps} from 'next/app' | ||
|
||
export default function App({ | ||
Component, | ||
pageProps, | ||
}: { | ||
Component: React.ComponentType | ||
pageProps: any | ||
}) { | ||
pageProps: {session, ...pageProps}, | ||
}: AppProps) { | ||
return ( | ||
<UserProvider> | ||
<SessionProvider session={session}> | ||
<Component {...pageProps} /> | ||
</UserProvider> | ||
</SessionProvider> | ||
) | ||
} |
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,4 @@ | ||
import NextAuth from 'next-auth' | ||
import {nextAuthConfig} from 'src/utils/authUtils' | ||
|
||
export default NextAuth(nextAuthConfig) |
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
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
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,27 @@ | ||
import type {ComponentType} from 'react' | ||
import {useEffect} from 'react' | ||
import {useSession} from 'next-auth/react' | ||
|
||
export const withPageAuthRequired = (Component: ComponentType) => { | ||
return function WithPageAuthRequired(props: any): JSX.Element { | ||
const {data: session, status} = useSession() | ||
|
||
useEffect(() => { | ||
if (session?.user || status === 'loading') return | ||
let returnToPath: string | ||
|
||
const currentLocation = window.location.toString() | ||
returnToPath = | ||
currentLocation.replace(new URL(currentLocation).origin, '') || '/' | ||
|
||
window.location.assign( | ||
`/api/auth/signin?callbackUrl=${encodeURIComponent(returnToPath)}`, | ||
) | ||
}, [session, status]) | ||
|
||
if (session?.user) | ||
return <Component user={session.user} {...(props as any)} /> | ||
|
||
return <div>Redirecting...</div> | ||
} | ||
} |
Oops, something went wrong.
96f51ec
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.
Successfully deployed to the following URLs:
theatre-playground – ./
theatre-playground-theatrejs.vercel.app
theatre-playground-git-main-theatrejs.vercel.app
theatre-playground.vercel.app