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
I'm using an auth lib to sign in users using server actions and would like to manually return a form error, if for instance the username/password is incorrect. Something like this:
exportconstsignInAction=actionClient.metadata({actionName: 'signIn'}).inputSchema(inputSchema).action(async({ parsedInput, ctx })=>{try{constsession=awaitauth.api.signInEmail({body: {email: parsedInput.email,password: parsedInput.password,},})// ...}catch(error){if(error.code==='INVALID_EMAIL_OR_PASSWORD'){// Return a form error 🤔}}})
Is there anything like returnValidationErrors for form errors, or would I need to validate credentials using refine on inputSchema? I would prefer to handle it in the action, as auth.api.signInEmail sets a cookie, so a session would be created twice, if I did it once in refine, to validate credentials, and then again in the action.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there!
Thanks for this great lib! 🙌
I'm using an auth lib to sign in users using server actions and would like to manually return a form error, if for instance the username/password is incorrect. Something like this:
Is there anything like
returnValidationErrorsfor form errors, or would I need to validate credentials usingrefineoninputSchema? I would prefer to handle it in the action, asauth.api.signInEmailsets a cookie, so a session would be created twice, if I did it once inrefine, to validate credentials, and then again in the action.Beta Was this translation helpful? Give feedback.
All reactions