Closed trusktr closed 8 years ago
For now, I'm doing this:
async function gotoFirstOrg(context, redirect, stop) {
const user = await Users.current() // wait for async result
const orgs = user.organizations().fetch()
const lastOrg = orgs[0].slug
FlowRouter.go(
'organization',
{organization: lastOrg},
{}
)
}
FlowRouter.route('/', {
name: 'home',
triggersEnter: [
checkLogin,
gotoFirstOrg,
],
action: function (params) {}
})
gotoFirstOrg is the last trigger function, and the action is empty, so even though it is currently impossible to prevent the action with redirect
or stop
, it doesn't really matter in this case.
Async would be nice!
As I said earlier, you need to get do this on the client side. Implement the redirect logic in the client side, if you need to get the userInfo for the redirect.
Just show a message to the user saying waiting, then do the redirect.
I've got a trigger that needs the current user's data:
Allowing async code would make it easier to solve this problem.