Skip to content

Commit

Permalink
fix: create a new object for the session callback (#1330)
Browse files Browse the repository at this point in the history
* spread new object

* whoops

* Create .changeset/itchy-cooks-sell.md

---------

Co-authored-by: Christopher Ehrlich <[email protected]>
  • Loading branch information
juliusmarminge and c-ehrlich committed Apr 5, 2023
1 parent ee55a02 commit 85997e0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-cooks-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: create a new object for the session callback
2 changes: 1 addition & 1 deletion cli/src/installers/dependencyVersionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
export const dependencyVersionMap = {
// NextAuth.js
"next-auth": "4.20.1", // TODO: undo after https://github.com/nextauthjs/next-auth/issues/7132 is fixed
"next-auth": "^4.21.0",
"@next-auth/prisma-adapter": "^1.0.5",

// Prisma
Expand Down
14 changes: 7 additions & 7 deletions cli/template/extras/src/server/auth/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ declare module "next-auth" {
*/
export const authOptions: NextAuthOptions = {
callbacks: {
session({ session, user }) {
if (session.user) {
session.user.id = user.id;
// session.user.role = user.role; <-- put other properties on the session here
}
return session;
},
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
providers: [
DiscordProvider({
Expand Down
14 changes: 7 additions & 7 deletions cli/template/extras/src/server/auth/with-prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ declare module "next-auth" {
*/
export const authOptions: NextAuthOptions = {
callbacks: {
session({ session, user }) {
if (session.user) {
session.user.id = user.id;
// session.user.role = user.role; <-- put other properties on the session here
}
return session;
},
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
adapter: PrismaAdapter(prisma),
providers: [
Expand Down

0 comments on commit 85997e0

Please sign in to comment.