reactjs - transition.retry() seems to be removing the ‘?’ from the query-string -
i using willtransitionto
static method auth. here’s example i’m following.
my transition.retry()
going original route along it’s original query-string. query-string missing question mark @ beginning, instead of going route intended in transition, it’s going /authtoken=xyz123
so,
- the user goes http://wickedsweet-react-site.com/?authtoken=xyz123
- react routes (via
transition.redirect
) http://wickedsweet-react-site.com/waitforserverauth - server authing , returns
- react routes (via
transition.retry()
) http://wickedsweet-react-site.com/authtoken=xyz123 oops
how can avoid stripping of ?
? incidentally, don’t want authtoken query string @ point because we've authed, now, that’s secondary concern.
here willtransitionto
method.
mixins: [reflux.connect(stores.authdatastore, 'auth_data')], statics: { willtransitionto: function (transition, params, query) { var auth_data = stores.authdatastore.getdata(); if (!auth_data.authenticated) { some_global_object.authtransition = transition; if (query.authtoken && !_.isempty(query.authtoken)) { auth.authenticate({token: query.authtoken}); // tells server auth transition.redirect("/waitforserverauth", params, {}); //don’t want query-string after point return; } } } }
for authentication passing token query-string parameter called ‘authtoken’. when user passes in authtoken using willtransitionto
ask server authenticate , redirect user waitingforauth page listens server’s auth. here’s waitingforauth react page.
var waitingforserverauth = react.createclass({ mixins: [reflux.connect(stores.authdatastore, 'auth_data')], componentwillupdate: function(nextprops, nextstate) { if (nextstate.auth_data.authenticated && some_global_object.authtransition) { some_global_object.authtransition.retry(); } }, render: function() { return (<div><loading /></div>); } });
when server returns auth , token valid, waitingforauth implements componentwillupdate
retry original transition aborted redirect.
Comments
Post a Comment