diff --git a/assets/scripts/app/auth.coffee b/assets/scripts/app/auth.coffee index 46dda80f..d5661c4e 100644 --- a/assets/scripts/app/auth.coffee +++ b/assets/scripts/app/auth.coffee @@ -14,9 +14,9 @@ if user = Travis.__container__.lookup('controller:currentUser').get('content') user.unload() Travis.__container__.lookup('controller:currentUser').set('content', null) - if router = Travis.__container__.lookup('router:main') + if controller = Travis.__container__.lookup('controller:currentUser') try - router.send('afterSignOut') + controller.send('afterSignOut') catch e throw e unless e.message =~ /There are no active handlers/ @@ -66,10 +66,10 @@ @set('state', 'signed-in') Travis.trigger('user:signed_in', data.user) - if router = Travis.__container__.lookup('router:main') + if controller = Travis.__container__.lookup('controller:currentUser') Ember.run.next => try - router.send('afterSignIn') + controller.send('afterSignIn') catch e throw e unless e =~ /There are no active handlers/ || e =~ /Can't trigger action "afterSignIn/ @refreshUserData(data.user) diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 8a8d0fde..ac225f0f 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -8,16 +8,6 @@ Ember.Router.reopen @_super(url) Travis.Route = Ember.Route.extend - afterSignIn: -> - if transition = Travis.auth.get('afterSignInTransition') - Travis.auth.set('afterSignInTransition', null) - transition.retry() - else - @transitionTo('index.current') if @constructor == Travis.AuthRoute || @constructor.superclass == Travis.AuthRoute - - afterSignOut: -> - @transitionTo('index.current') - renderFirstSync: -> @transitionTo 'first_sync' @@ -65,11 +55,13 @@ Travis.ApplicationRoute = Travis.Route.extend renderFirstSync: -> @renderFirstSync() - afterSignIn: (path) -> - @afterSignIn(path) + afterSignIn: -> + if transition = Travis.auth.get('afterSignInTransition') + Travis.auth.set('afterSignInTransition', null) + transition.retry() afterSignOut: -> - @afterSignOut() + @transitionTo('index.current') Travis.Router.reopen transitionTo: -> @@ -377,6 +369,11 @@ Travis.AuthRoute = Travis.Route.extend deactivate: -> @controllerFor('auth').set('redirected', false) + actions: + afterSignIn: -> + @transitionTo('index.current') + return true + Travis.RepoSettingsRoute = Travis.Route.extend setupController: (controller, model) -> # TODO: if repo is just a data hash with id and slug load it