How to redirect an Ember page without rendering?Ember authentication best practices?Ember + web api single page redirectConditional redirect in ember before/upon page loadember-simple-auth: saving user's URL after ajax errorEmber AJAX routeHow to redirect to login page if get the 401 error when I use ember-simple-auth?Ember js - Redirect if page is accessed by URLAjax call on page load in ember jsHandle redirection in async callsrendering html using laravel and ember js

"Best practices" for formulating MIPs

Aligning arrays within arrays within another array

Is there a connection between representation theory and PDEs?

Are the Gray and Death Slaad's Bite and Claw attacks magical?

How soon after takeoff can you recline your airplane seat?

What could a Medieval society do with excess animal blood?

Is it normal for professors to hold their graduate students "hostage?"

To “Er” Is Human

Why should I allow multiple IP addresses on a website for a single session?

Finding an optimal set without forbidden subsets

What is the meaning of "it" in "as luck would have it"?

How to model a Coral or Sponge Structure?

Installed software from source, how to say yum not to install it from package?

Runtime too long for NDSolveValue, FindRoot breaks down at sharp turns

Is my background sufficient to start Quantum Computing

Is it OK to throw pebbles and stones in streams, waterfalls, ponds, etc.?

Why is quantum gravity non-renormalizable?

How does entropy depend on location and scale?

Are the plates of a battery really charged?

Which are more efficient in putting out wildfires: planes or helicopters?

Could citing a database like libgen get one into trouble?

GFCI versus circuit breaker

What happened to the Apollo 1 rocket?

Can I hire several veteran soldiers to accompany me?



How to redirect an Ember page without rendering?


Ember authentication best practices?Ember + web api single page redirectConditional redirect in ember before/upon page loadember-simple-auth: saving user's URL after ajax errorEmber AJAX routeHow to redirect to login page if get the 401 error when I use ember-simple-auth?Ember js - Redirect if page is accessed by URLAjax call on page load in ember jsHandle redirection in async callsrendering html using laravel and ember js













0















We have an Ember UI that we're porting to a Single Sign-on provider. This is behind a server-side feature flag such that, when the flag is on, the user is redirected to the SSO provider login portal and, when the flag is off, the user may still login through an Ember route.



I have this functioning with a call to a server endpoint in the Ember Route beforeModel() call. However, since this is an asynchronous call, the page continues rendering before the request returns, the results processed and the browser redirected. Thus, the user can briefly see the old login form before being redirected to the SSO portal. I would prefer that the user only see a blank browser window before the SSO portal is shown.



Is there a way to get the Route beforeModel() method to block on the results of a server call? I tried putting an explicit call to the super.beforeModel() only after the ajax callback has been processed, but Ember doesn't seem to wait for that to finish before proceeding with the rendering.



return Em.Route.extend(/** @lends application.LoginRoute# */{
beforeModel: function() {
var route = this;
return Ember.$.ajax(
'/ws/ssoEnabled',
'success': function(json)
Em.Logger.info("[LOGIN ROUTE] SSO Redirect information:", json);
if (json.isSsoEnabled === true)
Em.Logger.info("[LOGIN ROUTE] Redirecting to", json.ssoRedirectUrl);
window.location.replace(json.ssoRedirectUrl);
return;

route._super.beforeModel();
,
'error': function(reason)
Em.Logger.error("SSO detection failed", reason);
);
,


(Roughly that's what it does; there's some global syntactic sugar helper methods that abstract the Ember.$.ajax call.)



Does the model loading block rendering until loading? I hesitate to experiment because the login pages do not have a model defined, so it would take a bit more new code.



The application is structured somewhat oddly. The Login pages are actually a separate app on Ember v2.4, so I can hook anywhere in the application code without worrying about breaking the actual app. I have tried also hooking into the Application and only calling the Ember.Application.create() method from inside the server call promise resolution. However, it seems that loading the login page components (via RequireJS) at all triggers their render.










share|improve this question
























  • I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

    – Enno
    Apr 1 at 10:58











  • I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

    – Patrick M
    Apr 1 at 13:53















0















We have an Ember UI that we're porting to a Single Sign-on provider. This is behind a server-side feature flag such that, when the flag is on, the user is redirected to the SSO provider login portal and, when the flag is off, the user may still login through an Ember route.



I have this functioning with a call to a server endpoint in the Ember Route beforeModel() call. However, since this is an asynchronous call, the page continues rendering before the request returns, the results processed and the browser redirected. Thus, the user can briefly see the old login form before being redirected to the SSO portal. I would prefer that the user only see a blank browser window before the SSO portal is shown.



Is there a way to get the Route beforeModel() method to block on the results of a server call? I tried putting an explicit call to the super.beforeModel() only after the ajax callback has been processed, but Ember doesn't seem to wait for that to finish before proceeding with the rendering.



return Em.Route.extend(/** @lends application.LoginRoute# */{
beforeModel: function() {
var route = this;
return Ember.$.ajax(
'/ws/ssoEnabled',
'success': function(json)
Em.Logger.info("[LOGIN ROUTE] SSO Redirect information:", json);
if (json.isSsoEnabled === true)
Em.Logger.info("[LOGIN ROUTE] Redirecting to", json.ssoRedirectUrl);
window.location.replace(json.ssoRedirectUrl);
return;

route._super.beforeModel();
,
'error': function(reason)
Em.Logger.error("SSO detection failed", reason);
);
,


(Roughly that's what it does; there's some global syntactic sugar helper methods that abstract the Ember.$.ajax call.)



Does the model loading block rendering until loading? I hesitate to experiment because the login pages do not have a model defined, so it would take a bit more new code.



The application is structured somewhat oddly. The Login pages are actually a separate app on Ember v2.4, so I can hook anywhere in the application code without worrying about breaking the actual app. I have tried also hooking into the Application and only calling the Ember.Application.create() method from inside the server call promise resolution. However, it seems that loading the login page components (via RequireJS) at all triggers their render.










share|improve this question
























  • I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

    – Enno
    Apr 1 at 10:58











  • I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

    – Patrick M
    Apr 1 at 13:53













0












0








0








We have an Ember UI that we're porting to a Single Sign-on provider. This is behind a server-side feature flag such that, when the flag is on, the user is redirected to the SSO provider login portal and, when the flag is off, the user may still login through an Ember route.



I have this functioning with a call to a server endpoint in the Ember Route beforeModel() call. However, since this is an asynchronous call, the page continues rendering before the request returns, the results processed and the browser redirected. Thus, the user can briefly see the old login form before being redirected to the SSO portal. I would prefer that the user only see a blank browser window before the SSO portal is shown.



Is there a way to get the Route beforeModel() method to block on the results of a server call? I tried putting an explicit call to the super.beforeModel() only after the ajax callback has been processed, but Ember doesn't seem to wait for that to finish before proceeding with the rendering.



return Em.Route.extend(/** @lends application.LoginRoute# */{
beforeModel: function() {
var route = this;
return Ember.$.ajax(
'/ws/ssoEnabled',
'success': function(json)
Em.Logger.info("[LOGIN ROUTE] SSO Redirect information:", json);
if (json.isSsoEnabled === true)
Em.Logger.info("[LOGIN ROUTE] Redirecting to", json.ssoRedirectUrl);
window.location.replace(json.ssoRedirectUrl);
return;

route._super.beforeModel();
,
'error': function(reason)
Em.Logger.error("SSO detection failed", reason);
);
,


(Roughly that's what it does; there's some global syntactic sugar helper methods that abstract the Ember.$.ajax call.)



Does the model loading block rendering until loading? I hesitate to experiment because the login pages do not have a model defined, so it would take a bit more new code.



The application is structured somewhat oddly. The Login pages are actually a separate app on Ember v2.4, so I can hook anywhere in the application code without worrying about breaking the actual app. I have tried also hooking into the Application and only calling the Ember.Application.create() method from inside the server call promise resolution. However, it seems that loading the login page components (via RequireJS) at all triggers their render.










share|improve this question
















We have an Ember UI that we're porting to a Single Sign-on provider. This is behind a server-side feature flag such that, when the flag is on, the user is redirected to the SSO provider login portal and, when the flag is off, the user may still login through an Ember route.



I have this functioning with a call to a server endpoint in the Ember Route beforeModel() call. However, since this is an asynchronous call, the page continues rendering before the request returns, the results processed and the browser redirected. Thus, the user can briefly see the old login form before being redirected to the SSO portal. I would prefer that the user only see a blank browser window before the SSO portal is shown.



Is there a way to get the Route beforeModel() method to block on the results of a server call? I tried putting an explicit call to the super.beforeModel() only after the ajax callback has been processed, but Ember doesn't seem to wait for that to finish before proceeding with the rendering.



return Em.Route.extend(/** @lends application.LoginRoute# */{
beforeModel: function() {
var route = this;
return Ember.$.ajax(
'/ws/ssoEnabled',
'success': function(json)
Em.Logger.info("[LOGIN ROUTE] SSO Redirect information:", json);
if (json.isSsoEnabled === true)
Em.Logger.info("[LOGIN ROUTE] Redirecting to", json.ssoRedirectUrl);
window.location.replace(json.ssoRedirectUrl);
return;

route._super.beforeModel();
,
'error': function(reason)
Em.Logger.error("SSO detection failed", reason);
);
,


(Roughly that's what it does; there's some global syntactic sugar helper methods that abstract the Ember.$.ajax call.)



Does the model loading block rendering until loading? I hesitate to experiment because the login pages do not have a model defined, so it would take a bit more new code.



The application is structured somewhat oddly. The Login pages are actually a separate app on Ember v2.4, so I can hook anywhere in the application code without worrying about breaking the actual app. I have tried also hooking into the Application and only calling the Ember.Application.create() method from inside the server call promise resolution. However, it seems that loading the login page components (via RequireJS) at all triggers their render.







ember.js ember-2.0.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 20:04







Patrick M

















asked Mar 25 at 17:34









Patrick MPatrick M

6,9628 gold badges49 silver badges90 bronze badges




6,9628 gold badges49 silver badges90 bronze badges












  • I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

    – Enno
    Apr 1 at 10:58











  • I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

    – Patrick M
    Apr 1 at 13:53

















  • I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

    – Enno
    Apr 1 at 10:58











  • I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

    – Patrick M
    Apr 1 at 13:53
















I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

– Enno
Apr 1 at 10:58





I'd wrap the ajax call in another promise and use transition.abort() (see docs) before the redirect to an external page; If no redirect should happen the promise can resolve as normal (and probaply call _super).

– Enno
Apr 1 at 10:58













I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

– Patrick M
Apr 1 at 13:53





I've since discovered that route.beforeModel() is not necessarily defined in our version of Ember and calling it can result in an error logged to the console. Interesting tip on the abort(), I'll give it a shot later today.

– Patrick M
Apr 1 at 13:53










2 Answers
2






active

oldest

votes


















2














do the redirect in the application routes beforeModel hook.
A services init hook is not the right place.
Better call a custom method on your service from the application routes beforeModel hook.



Maybe have a look how ember-simple-auths mixins work.






share|improve this answer























  • Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

    – Patrick M
    Mar 25 at 19:45


















0














Ember’s beforeModel hook has been able to block UI rendering since the Ember 1.x era, so it is possible to do what you want.



However, if you are doing jQuery Ajax calls, you’ll need to make sure you are returning a spec-compliant Promise in the hook. jQuery historically did NOT return that type of promise (though that depends on your version of jQuery and the way you call ajax iirc). Worth checking as the behavior you’re describing fits with a non-promise being returned






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343543%2fhow-to-redirect-an-ember-page-without-rendering%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    do the redirect in the application routes beforeModel hook.
    A services init hook is not the right place.
    Better call a custom method on your service from the application routes beforeModel hook.



    Maybe have a look how ember-simple-auths mixins work.






    share|improve this answer























    • Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

      – Patrick M
      Mar 25 at 19:45















    2














    do the redirect in the application routes beforeModel hook.
    A services init hook is not the right place.
    Better call a custom method on your service from the application routes beforeModel hook.



    Maybe have a look how ember-simple-auths mixins work.






    share|improve this answer























    • Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

      – Patrick M
      Mar 25 at 19:45













    2












    2








    2







    do the redirect in the application routes beforeModel hook.
    A services init hook is not the right place.
    Better call a custom method on your service from the application routes beforeModel hook.



    Maybe have a look how ember-simple-auths mixins work.






    share|improve this answer













    do the redirect in the application routes beforeModel hook.
    A services init hook is not the right place.
    Better call a custom method on your service from the application routes beforeModel hook.



    Maybe have a look how ember-simple-auths mixins work.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 25 at 17:56









    LuxLux

    11.9k3 gold badges29 silver badges60 bronze badges




    11.9k3 gold badges29 silver badges60 bronze badges












    • Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

      – Patrick M
      Mar 25 at 19:45

















    • Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

      – Patrick M
      Mar 25 at 19:45
















    Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

    – Patrick M
    Mar 25 at 19:45





    Good tip. I found this documentation page that proves your point about redirecting in the route: guides.emberjs.com/release/routing/redirection However, I still get a screen flash of the form rendering. I still need to figure out how to block. I will edit my question with the new code.

    – Patrick M
    Mar 25 at 19:45











    0














    Ember’s beforeModel hook has been able to block UI rendering since the Ember 1.x era, so it is possible to do what you want.



    However, if you are doing jQuery Ajax calls, you’ll need to make sure you are returning a spec-compliant Promise in the hook. jQuery historically did NOT return that type of promise (though that depends on your version of jQuery and the way you call ajax iirc). Worth checking as the behavior you’re describing fits with a non-promise being returned






    share|improve this answer



























      0














      Ember’s beforeModel hook has been able to block UI rendering since the Ember 1.x era, so it is possible to do what you want.



      However, if you are doing jQuery Ajax calls, you’ll need to make sure you are returning a spec-compliant Promise in the hook. jQuery historically did NOT return that type of promise (though that depends on your version of jQuery and the way you call ajax iirc). Worth checking as the behavior you’re describing fits with a non-promise being returned






      share|improve this answer

























        0












        0








        0







        Ember’s beforeModel hook has been able to block UI rendering since the Ember 1.x era, so it is possible to do what you want.



        However, if you are doing jQuery Ajax calls, you’ll need to make sure you are returning a spec-compliant Promise in the hook. jQuery historically did NOT return that type of promise (though that depends on your version of jQuery and the way you call ajax iirc). Worth checking as the behavior you’re describing fits with a non-promise being returned






        share|improve this answer













        Ember’s beforeModel hook has been able to block UI rendering since the Ember 1.x era, so it is possible to do what you want.



        However, if you are doing jQuery Ajax calls, you’ll need to make sure you are returning a spec-compliant Promise in the hook. jQuery historically did NOT return that type of promise (though that depends on your version of jQuery and the way you call ajax iirc). Worth checking as the behavior you’re describing fits with a non-promise being returned







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 3 at 9:27









        acorncomacorncom

        5,6621 gold badge14 silver badges30 bronze badges




        5,6621 gold badge14 silver badges30 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343543%2fhow-to-redirect-an-ember-page-without-rendering%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현