manually including the jwt token
I am new to formio and I have a query that I have not found any solution to.
My system consists of a sailsjs back end, a react front end, and a local instance of form io. I have connected to the authentication of both the sails and formio. But with this custom authentication, I cant seem to be able to make formio properly authenticate my user.
My question is, where does the formio token gets stored when i log in, and from where is it being read, and adding to the headers when I am trying to submit/update submission.
The token is stored in localStorage as formioToken. When sent to servers it is at headers['x-jwt-token'].
You can modify this by creating a formio.js plugin that intercepts requests and changes the location of the token. https://github.com/formio/formio.js/wiki/Fetch-Plugin-API
Thank you very much @randallknutson . This has resolved my issues.
Hi sorry to disturb again.
When calling the getForm() action, Im getting an error because the root selector is getting problem. _selectors.selectRoot(...) is undefined. I think the reason is because my formio reducers are not in the root state, but in a sub-state called formioStore
formioStore: combineReducers({
auth: formioAuth(),
form: form({ name: 'form' }),
forms: forms({ name: 'forms', query: { type: 'form', tags: 'common' } }),
submission: submission({ name: 'submission' }),
submissions: submissions({ name: 'submissions' }),
event: combineReducers({
form: form({ name: 'event' }),
submission: submission({ name: 'event' }),
submissions: submissions({ name: 'event' }),
}),
}),
So My question is, Is this the reason for the error and if so is there a way to change the default root in some configuration in formio?
This is the error in chrome:
TypeError: Cannot read property 'form' of undefined
selectForm
C:/Users/babac/Indus Action/cms-front-end/node_modules/react-formio/lib/modules/form/selectors.js:11
8 | var _selectors = require('../root/selectors');
9 |
10 | var selectForm = exports.selectForm = function selectForm(name, state) {
> 11 | return (0, _selectors.selectRoot)(name, state).form;
12 | };
I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!