Last active
December 17, 2015 16:59
-
-
Save ybart/5642728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AuthenticatedRoute = Ember.Route.extend | |
redirect: -> | |
controller = App.__container__.lookup('controller:user') | |
unless controller.get 'isSignedIn' | |
App.application.set('nextRoute', @routeName) | |
App.application.set('nextContext', @context) | |
@transitionTo 'index' # this is the login page | |
deserialize: (params) -> | |
context = @_super(params) | |
@set('context', context) | |
context | |
App.MyRoute = App.AuthenticatedRoute.extend | |
model: (params) -> | |
# signedIn = App.__container__.lookup('controller:user').get('isSignedIn') | |
# App.User.find(params.user_id) if signedIn | |
App.User.find(params.user_id) # Fails with HTTP 401 when logged out, in this case redirect is never called (Ember 1.0.0rc3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment