mardi 29 mars 2016

preload data after sessionAuthenticated at application route globally

After calling a custom authenticate method at login route, the action sessionAuthenticated is triggered at the application level (ApplicationRouteMixin).

ie:

sessionAuthenticated() {
    this._super(...arguments);

    let _this = this;
    return this_loadUser().catch(function() {
        _this.get('session').invalidate();

    });

}

This works, however, if I want to preload extra data, sessionAuthenticated does not wait until all the promises are resolved. And since the beforeModel and afterModel hooks were already initially at the application route level, the only way this works reliably is when refreshing the page while session is active (logged in).

In short; when at the login route, calling authenticate, after successful authenticate the sessionAuthenticated action is triggered at the application route, but with extra data needed to be preloaded globally, at the application route level. The sessionAuthenticated doesn't see to wait until all promises are resolved.




Aucun commentaire:

Enregistrer un commentaire