Form Data can not be accessed when calling `authenticator.authenticate`
fkrauthan opened this issue · comments
Describe the bug
I am trying to implement some additional processing on top of authenticator.authenticate
that requires me to access formData
before calling authenticate
. However, given that formData can only be read once it errors out during the authenticate
call.
Your Example Website or App
NA
Steps to Reproduce the Bug or Issue
- Call
await request.formData();
- Call
await authenticator.authenticate('form-login', request, {});
Expected behavior
It works fine and logs me in (and/or allows me to pass in the already parsed formData
)
Screenshots or Videos
No response
Platform
- OS: Windows and Macos
- Browser: All Browsers
- Version: All Versions
Additional context
No response
You need to clone the request before calling authenticator.authenticate
if you plan to read the FormData
let formData = await request.clone().formData()
await authenticator.authenticate('strategy', request, options);
Ah cool, I will give that a try. Might be worth documenting as the error you get is not very obvious and especially in cases like password reset or activation this might be a sort of common use-case.