Kris.O
Kris.O

Reputation: 13

Ember Simple Auth subdomain redirects

I've been able to successfully setup multiple Ember applications with shared Ember Simple Auth cookie based authentication. The next step of my journey is to setup proper redirects between applications. Hear me out.

Scenario A (this works out of the box, yay!)

Scenario B (this works out of the box, yay!)

Scenario C (this is what I need to achieve)

Any help or guidance would be much appreciated. I wonder if I can achieve Scenario C with Ember Simple Auth only, or if I need to write custom redirect logic in beforeModel on subdomains, etc.

Upvotes: 1

Views: 307

Answers (1)

marcoow
marcoow

Reputation: 4062

You'll be able get scenario C working by overriding the AuthenticatedRouteMixin's beforeModel method. That will by default to an (Ember.js) transition to the login route but in your case you want sth. like window.location.replace('domain.com/login') and remember the current URL in a cookie or so. In order to redirect to app-a.domain.com/deep/link/resource after the user logged in you'll need to override the ApplicationRouteMixin's sessionAuthenticated method so that it redirects to the previous URL remembered in the cookie if that's present and falls back to the default behavior if not.

Overall, getting this to work should be pretty straight forward actually following these steps.

Upvotes: 0

Related Questions