You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE : CODE IN THE FILE IS ATTACHED IN THE MARKDOWN AT THE LAST
Hey I am not sure if I need to share my whole project or just this file is enough .
Anyway here is the short explaination ->
This file is the Options file for next js authentication. I am using credentials method.
In my project I have used type any at many places and to follow best practices I wanted to change them.
In the options.ts file the authorize method gives me some error that type of credentials doesn't match even though its matching. I spend a lot of time just to see where it went wrong.
Then chatgpt recommended me to run npm run lint which will show the potential errors.
All the errors in there is not from this file and when I locally ran the code npm run dev , the login functionality is working fine.
But still the authorize function is giving me errors in vs code.
I don't want that in future same thing repeats as I spend my energy only to find out in actual there were no errors.
Note : I already matched the typescript versions of the project and vs code to avoid any conflictions.
`Options.ts` file code - dropdown
import{NextAuthOptions}from"next-auth";importCredentialsProviderfrom"next-auth/providers/credentials";importbcryptfrom"bcryptjs";importdbConnectfrom"@/lib/dbConnect";importUserModel,{User}from"@/model/User";exportconstauthOptions : NextAuthOptions={providers: [CredentialsProvider({id : "credentials",name : "Credentials",credentials : {identifier : {label : "Email or Username",type : "text"},password : {label : "Password",type : "password"},},asyncauthorize(credentials?: Record<"identifier"|"password",string>|undefined) : Promise<User|null>{if(!credentials)returnnull;awaitdbConnect();try{constuser=awaitUserModel.findOne({$or : [{email : credentials.identifier},{username : credentials.identifier}]});if(!user){thrownewError("No user found with such username or email");}if(!user.isVerified){thrownewError("Please verify your account before login");}constisCorrectPassword=awaitbcrypt.compare(credentials.password,user.password)if(isCorrectPassword){returnuser;}else{thrownewError("Incorrect password")}}catch(error){consttypedError=errorasError&{message : string};if(typedError.message){thrownewError(typedError.message)}elsethrownewError("An error occured while trying to login");}},}),],callbacks : {asyncjwt({token , user }){if(user){token._id=user._id?.toString();token.isVerified=user.isVerified;token.isAcceptingMessages=(userasUser).isAcceptingResponse;token.username=user.username}returntoken;},asyncsession({session, token}){if(token){session.user._id=token._id;session.user.isVerified=token.isVerified;session.user.isAcceptingMessages=token.isAcceptingMessages;session.user.username=token.username;}returnsession;}},pages : {signIn : "/signin",},session: {strategy: 'jwt',},secret : process.env.NEXTAUTH_SECRET}
VS Code version: Code 1.96.4 (cd4ee3b, 2025-01-16T00:16:19.038Z)
OS version: Windows_NT x64 10.0.26100
Modes:
We closed this issue because it is a question about using VS Code rather than an issue or feature request. Please search for help on StackOverflow, where the community has already answered thousands of similar questions. You may find their guide on asking a new question helpful if your question has not already been asked. See also our issue reporting guidelines.
Type: Bug
NOTE : CODE IN THE FILE IS ATTACHED IN THE MARKDOWN AT THE LAST
Hey I am not sure if I need to share my whole project or just this file is enough .
Anyway here is the short explaination ->
This file is the Options file for next js authentication. I am using credentials method.
In my project I have used type
any
at many places and to follow best practices I wanted to change them.In the
options.ts
file theauthorize
method gives me some error that type of credentials doesn't match even though its matching. I spend a lot of time just to see where it went wrong.Then chatgpt recommended me to run
npm run lint
which will show the potential errors.All the errors in there is not from this file and when I locally ran the code
npm run dev
, the login functionality is working fine.But still the authorize function is giving me errors in vs code.
I don't want that in future same thing repeats as I spend my energy only to find out in actual there were no errors.
Note : I already matched the typescript versions of the project and vs code to avoid any conflictions.
`Options.ts` file code - dropdown
VS Code version: Code 1.96.4 (cd4ee3b, 2025-01-16T00:16:19.038Z)
OS version: Windows_NT x64 10.0.26100
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Extensions (32)
A/B Experiments
The text was updated successfully, but these errors were encountered: