Voj*_*jin 3 typescript next.js prisma next-auth t3
我正在关注本教程,了解如何在下一个身份验证会话中添加角色。不幸的是,当我添加profile属性时,我发现配置文件的未定义行为丢失。关于打字稿也有错误。这是我这边的错误,还是已知的错误,因为我找不到任何内容。
到目前为止,这是我的代码:
export const authOptions: AuthOptions = {
secret: process.env.NEXT_PUBLIC_SECRET!,
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
// profile: async (profile) => {
// return { ...profile, role: profile.role ?? Role.USER };
// },
}),
],
pages: {
signIn: "/",
},
adapter: PrismaAdapter(prisma),
};
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它与教程中的相同,当我注释掉配置文件部分时,我得到了没有角色的预期行为。任何帮助,将不胜感激!
Next.js 版本:13.4.1(应用程序目录)
小智 14
我刚刚将“id: profile.sub”添加到我的 GoogleProvider 中,此后就没有错误了
GoogleProvider({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code"
}
},
async profile(profile) {
return {
id: profile.sub,
name: profile.name,
firstname: profile.given_name,
lastname: profile.family_name,
email: profile.email,
image: profile.picture,
}
},
}),Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |