TS7006: Parameter credentials implicitly has an any type. TS2322: Type { id: string;…
- User
TS7006: Parameter credentials implicitly has an any type. TS2322: Type { id: string; name: string; type: string; credentials: { phoneNumber: { label: string; type: string; }; otp: { label: string; type: string; }; }; authorize: (credentials: any) => Promise; } is not assignable to type Provider Type '{ id: string; name: string; type: string; credentials: { phoneNumber: { label: string; type: string; }; otp: { label: string; type: string; }; }; authorize: (credentials: any) => Promise; }' is not assignable to type 'CredentialsConfig<Record<string, CredentialInput>> & InternalProviderOptions'. Type '{ id: string; name: string; type: string; credentials: { phoneNumber: { label: string; type: string; }; otp: { label: string; type: string; }; }; authorize: (credentials: any) => Promise; }' is not assignable to type 'CredentialsConfig<Record<string, CredentialInput>>'. Types of property type are incompatible. Type string is not assignable to type "credentials" import NextAuth from "next-auth"; import axios from "axios";
const SMSOTPProvider = { id: "sms-otp", name: "SMS OTP", type: "credentials", credentials: { phoneNumber: { label: "Phone Number", type: "tel" }, otp: { label: "OTP", type: "text" }, }, authorize: async (credentials) => { try { console.log("Authorize function called with credentials:", credentials);
const { phoneNumber, otp } = credentials; console.log("Parsed credentials:", { phoneNumber, otp }); // Verify OTP const isValid = await verifyOTP(phoneNumber, otp); console.log("OTP verification result:", isValid); if (isValid) { // Fetch or create user based on phone number const user = await getUserByPhoneNumber(phoneNumber); console.log("User retrieved:", user); return user; } console.log("OTP verification failed"); return null; } catch (error) { console.error("Error in authorize function:", error); throw error; }}, };
export const { handlers, auth } = NextAuth({ providers: [SMSOTPProvider], debug: true, // Enable debug mode for more detailed logs });
async function generateOTP(phoneNumber: string): Promise { try { const response = await axios.post( "https://api.bimehtakmili.com/api/login/generate_token", { mobile_no: phoneNumber, }, { headers: { "Content-Type": "application/json", accept: "application/json", }, }, );
return response.status === 200;} catch (error) { console.error("Error generating OTP:", error); return false; } }
async function verifyOTP(phoneNumber: string, otp: string): Promise { try { const response = await axios.post( "https://api.bimehtakmili.com/api/login/verify_otp", { mobile_no: phoneNumber, otp: otp, }, { headers: { "Content-Type": "application/json", accept: "application/json", }, }, );
- Assistant
- User
TS2322: Type { id: string; name: string; type: string; credentials: { phoneNumber: CredentialInput; otp: CredentialInput; }; authorize: (credentials: SMSCredentials) => Promise; } is not assignable to type Provider Type { id: string; name: string; type: string; credentials: { phoneNumber: CredentialInput; otp: CredentialInput; }; authorize: (credentials: SMSCredentials) => Promise; } is not assignable to type CredentialsConfig<Record<string, CredentialInput>> & InternalProviderOptions Type { id: string; name: string; type: string; credentials: { phoneNumber: CredentialInput; otp: CredentialInput; }; authorize: (credentials: SMSCredentials) => Promise; } is not assignable to type CredentialsConfig<Record<string, CredentialInput>> Types of property type are incompatible. Type string is not assignable to type "credentials"
- Assistant
- User
TS2322: Type (credentials: SMSCredentials) => Promise is not assignable to type (credentials: Partial<Record<"phoneNumber" | "otp", unknown>>, request: Request) => Awaitable<User | null> Types of parameters credentials and credentials are incompatible. Type Partial<Record<"phoneNumber" | "otp", unknown>> is not assignable to type SMSCredentials Types of property phoneNumber are incompatible. Type unknown is not assignable to type string credentials. d. ts(53, 5): The expected type comes from property authorize which is declared here on type Partial<CredentialsConfig<{ phoneNumber: { label: string; type: string; }; otp: { label: string; type: string; }; }>>
- Assistant