Use action bubbling instead of checking for contructor in AuthRoute
This commit is contained in:
parent
98f1e62047
commit
8c513fd7d2
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user