我只在下一个身份验证中使用一个CredentialsProvider,但我对如何处理async authorize()自定义用户界面感到困惑。
我定义用户界面如下types/next-auth.d.ts:
import NextAuth from "next-auth"
declare module "next-auth" {
interface User {
id: string
address: string
name?: string
}
}
Run Code Online (Sandbox Code Playgroud)
这是提供者定义[...nextauth].ts:
CredentialsProvider({
name: "Ethereum",
credentials: {
message: {
label: "Message",
type: "text",
},
signature: {
label: "Signature",
type: "text",
},
},
async authorize(credentials) {
try {
const nextAuthUrl = process.env.NEXTAUTH_URL
if (!nextAuthUrl) return null
if (!credentials) return null
// [verify the credential here]
// "message" contains the verified information …Run Code Online (Sandbox Code Playgroud)