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
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
add a comment |
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
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 thatroute.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 theabort()
, I'll give it a shot later today.
– Patrick M
Apr 1 at 13:53
add a comment |
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
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
ember.js ember-2.0.0
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 thatroute.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 theabort()
, I'll give it a shot later today.
– Patrick M
Apr 1 at 13:53
add a comment |
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 thatroute.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 theabort()
, 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
add a comment |
2 Answers
2
active
oldest
votes
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.
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
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Apr 3 at 9:27
acorncomacorncom
5,6621 gold badge14 silver badges30 bronze badges
5,6621 gold badge14 silver badges30 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 theabort()
, I'll give it a shot later today.– Patrick M
Apr 1 at 13:53