-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional redirect #153
Comments
We have tried this approach, it works for simple Meteor.userId() but fails if you are basing your redirect on more advanced logic with data attached toMeteor.user() such as profile or roles. |
So my composer/component trial failed as well:
// components/layout.jsx
import UserControlsComponent from './user_controls_component.jsx';
import userComposer from '../composers/user.js';
const Layout = ({content = () => null}) => {
const UserControlsContainer = userComposer(UserControlsComponent);
return (
<div>
<header>
<UserControlsContainer />
</header>
<main>
{content()}
</main>
</div>
);
};
// composers/user.js
export const composer = ({context}, onData) => {
const {Meteor, Router} = context();
const user = Meteor.user();
if (! user) {
Router.go('login');
} else {
onData(null, {user});
}
};
// routes.jsx
import MainLayout from './components/layout.jsx';
export default function (injectDeps, {Router}) {
const MainLayoutCtx = injectDeps(MainLayout);
Router.route('/', {
name: 'index',
action() {
mount(MainLayoutCtx, {
content: () => ...
});
}
});
} The It is not possible to perform redirect inside composer function? EDIT: actually, the url has changed but the layout and components for |
Hi, in the spect is this:
Why this? Can you explain it to me? In mantra-kickstarter, there is a redirect preformed directly in route's action, is it correct? I've read in flow-router doc, the route's actions are idempotent, so they are called only once, if I understand.
That's probably the reason why this approach is not working for me, the
index
route's action isn't called after redirect from logout action:I didn't try the
triggerEnter
approach. I don't know if it will work. The composer/component approach will be my next trial probably.Thank you
The text was updated successfully, but these errors were encountered: