-
Notifications
You must be signed in to change notification settings - Fork 603
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
attemptedTransition never persists #1660
Comments
Forgot to mention. I'm using ESA 1.6.0 and ember 2.18.2. |
What are you trying to achieve? |
Just trying to redirect to the route that caused the initial transition to the login route. |
So when you follow the docs, users should automatically be forwarded to the originally requested route if a transition was previously intercepted. That works both for the situation where the intercepted transition was triggered from in the browser or it was a FastBoot request. Check the demo app - this is using out-of-the-box ESA functionality only. |
import Ember from 'ember';
import OAuth2ImplicitGrantCallbackMixin from 'ember-simple-auth/mixins/oauth2-implicit-grant-callback-route-mixin';
export default Ember.Route.extend(OAuth2ImplicitGrantCallbackMixin, {
authenticator: 'authenticator:oauth2',
}); This is my callback route which is used when the auth server responds with the hash. Below is my Application Route. import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin); Here's my login route. import Route from '@ember/routing/route';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
export default Route.extend(UnauthenticatedRouteMixin); Then I also have a bunch of routes that are using the AuthenticatedRouteMixin. For example here's an route called about which just displays a static but protected about page: import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin); Honestly I debated opening an issue because I figured this is going to be really difficult to reproduce. I may have to just grab your demo application and configure it against my auth source just to make sure it isn't related to simply redirecting from an external host. |
so what are the exact steps to reproduce the error with that setup (e.g. in particular what's the first request that's expected to be intercepted and which transitions happen after that)? |
I go to the about route to have it attempt the transition and then intercept and go to login (since it's a protected route) then after it logins it goes to the callback which then instead of retrying the transition from before, it always goes to index. Here's a log of what I see:
|
Tried to run the dummy application but it resulted in
I was following the guide from the README.md
yarn install causes the error and unfortunately I'm not familiar with what that command actually does. |
try |
That worked, and I got to learn more about yarn in the meantime. So I was able to test and the issue definitely the external redirect. You don't need to stage this. Use your demo application, go to the protected page so it redirects you to login, then use Google OAuth2 and login. It takes you back to index which means this problem exists for any external callback OAuth2 with the returned hash. |
I've been scratching my head over this, too. I started working on implementing the redirect logic myself, but as part of the process, came across documentation / references to I can also confirm that the Google OAuth2 login option in the demo app does indeed suffer from this issue, while the Resource Owner Password Credentials login option redirects to the protected page after login as expected. As per the title of this issue, it seems that it's not being persisted - so once the user is redirected to the external login page, the transition is gone. |
cleaning old issues |
I've attempted to use the built in attemptedTransition mechanics and it's never worked. I tried with CookieStorage and AdaptiveStorage but it never sets this despite it running the code to do the cookies.write() call and the set('session.attemptedTransition') call. Neither call actually changes the contents of the cookie or the localStorage no matter if it's fastboot or not.
I'm not sure how this is supposed to work but I just extended your AuthenticatedRouteMixin and stored the transition.targetName myself in localStorage. Then did the transition inside of the sessionAuthenticated method on the Application Route which is uing ApplicationRouteMixin.
I'm baffled at how I can code this to work flawlessly in less than 20 minutes but I burned hours debugging the ESA built in solution. I couldn't even get set attemptedTransition myself because it gets cleared by the callback route before getting to the applicationRoute's sessionAuthenticated.
The text was updated successfully, but these errors were encountered: