login with next-auth
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
So, im making a login system with next-auth using a custom page.
I guess its working fine (?), because im already getting the cookies, and i can successfully display
But, why isnt redirects or toast working? After pressing login it just like refreshes my page, I've tried
I guess its working fine (?), because im already getting the cookies, and i can successfully display
session.user.email on the profile page...But, why isnt redirects or toast working? After pressing login it just like refreshes my page, I've tried
e.preventDefault() but it doesnt work... (I meant i cant do e.preventDefault())17 Replies
Brown bearOP
thats my code
@Brown bear Click to see attachment
You can use router from
next-navigation , so instead of redirect, you use router.push('/myprofile')@Glö - Node js You can use router from `next-navigation` , so instead of redirect, you use `router.push('/myprofile')`
Brown bearOP
ive tried, doesnt work still
@Brown bear ive tried, doesnt work still
Place console logs under and above the success toast to detect if it gets to that stage at all
@Glö - Node js Place console logs under and above the success toast to detect if it gets to that stage at all
Brown bearOP
the page refreshes, cant even see the error log
@Brown bear the page refreshes, cant even see the error log
Ohh okay, it's the e.preventdefault then
Where you're submitting the form
Note that the e must be a prop in the function
@Glö - Node js Ohh okay, it's the e.preventdefault then
Brown bearOP
like this?
doesnt work tho i get an error
Argument of type '(data: LoginProps, event: FormEvent<HTMLFormElement>) => Promise<void>' is not assignable to parameter of type 'SubmitHandler<LoginProps>'.
Types of parameters 'event' and 'event' are incompatible.
Type 'BaseSyntheticEvent<object, any, any> | undefined' is not assignable to type 'FormEvent<HTMLFormElement>'.
Type 'undefined' is not assignable to type 'FormEvent<HTMLFormElement>'.ts(2345)
const onLogin: (data: LoginProps, event: FormEvent<HTMLFormElement>) => Promise<void>@Brown bear like this?
Not here
Brown bearOP
oh on the component?
The function that gets called initially when you press the login button
@Glö - Node js The function that gets called initially when you press the login button
Brown bearOP
wait inside the function or the component?