-
-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial working * add user side callback control * connect to blitz-auth * better error handling * initial working after submodule * Create fast-adults-guess.md * add submodule init and update to workflow * remove internal folder * cleanup * ignore tests from next-auth * add redirectUrl config and maintin consistency * move required files back to internals folder * remove submodule cloning * Patch NextAuth another time fix import issue fix import add path imports for the adapters Revert "add to blitz-auth" This reverts commit 246e62f. add to blitz-auth pnpm lock fix cleanup fix codegen remove nextauth submodule and internal folder and patch nextauth * Revert "Patch NextAuth" This reverts commit 31888fc. * switch * DRY * optional peerDependency * Delete .gitmodules * make it work with webpack alias * fix * split to new path * undo unnecessary changes * more fixes * add strong typing to nextauth adapter (#4104) * add strong typing to nextauth adapter * cleanup --------- Co-authored-by: Brandon Bayer <b@bayer.ws>
- Loading branch information
1 parent
3480d90
commit 6f18cbd
Showing
37 changed files
with
1,235 additions
and
209 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,6 @@ | ||
--- | ||
"@blitzjs/auth": minor | ||
"blitz": minor | ||
--- | ||
|
||
feature: Next Auth Adapter |
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,43 @@ | ||
import { api } from "src/blitz-server" | ||
import GithubProvider from "next-auth/providers/github" | ||
import { NextAuthAdapter, BlitzNextAuthOptions } from "@blitzjs/auth/next-auth" | ||
import db, { User } from "db" | ||
import { Role } from "types" | ||
|
||
// Has to be defined separately for `profile` to be correctly typed below | ||
const providers = [ | ||
GithubProvider({ | ||
clientId: process.env.GITHUB_CLIENT_ID as string, | ||
clientSecret: process.env.GITHUB_CLIENT_SECRET as string, | ||
}), | ||
] | ||
|
||
export default api( | ||
NextAuthAdapter({ | ||
successRedirectUrl: "/", | ||
errorRedirectUrl: "/error", | ||
providers, | ||
callback: async (user, account, profile, session) => { | ||
console.log("USER SIDE PROFILE_DATA", { user, account, profile }) | ||
let newUser: User | ||
try { | ||
newUser = await db.user.findFirstOrThrow({ where: { name: { equals: user.name } } }) | ||
} catch (e) { | ||
newUser = await db.user.create({ | ||
data: { | ||
email: user.email as string, | ||
name: user.name as string, | ||
role: "USER", | ||
}, | ||
}) | ||
} | ||
const publicData = { | ||
userId: newUser.id, | ||
role: newUser.role as Role, | ||
source: "github", | ||
} | ||
await session.$create(publicData) | ||
return { redirectUrl: "/" } | ||
}, | ||
}) | ||
) |
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 @@ | ||
src/server/adapters/next-auth/next-auth |
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 @@ | ||
export * from "./dist/next-auth" |
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 @@ | ||
module.exports = require("./dist/next-auth.cjs") |
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 @@ | ||
export * from "./passport/adapter" |
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,3 @@ | ||
export * from "./next-auth/adapter" | ||
export * from "./next-auth/types" | ||
export * from "./next-auth/webpack" |
Oops, something went wrong.