Use action bubbling instead of checking for contructor in AuthRoute
This commit is contained in:
parent
98f1e62047
commit
8c513fd7d2
assets/scripts/app
|
@ -14,9 +14,9 @@
|
||||||
if user = Travis.__container__.lookup('controller:currentUser').get('content')
|
if user = Travis.__container__.lookup('controller:currentUser').get('content')
|
||||||
user.unload()
|
user.unload()
|
||||||
Travis.__container__.lookup('controller:currentUser').set('content', null)
|
Travis.__container__.lookup('controller:currentUser').set('content', null)
|
||||||
if router = Travis.__container__.lookup('router:main')
|
if controller = Travis.__container__.lookup('controller:currentUser')
|
||||||
try
|
try
|
||||||
router.send('afterSignOut')
|
controller.send('afterSignOut')
|
||||||
catch e
|
catch e
|
||||||
throw e unless e.message =~ /There are no active handlers/
|
throw e unless e.message =~ /There are no active handlers/
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@
|
||||||
|
|
||||||
@set('state', 'signed-in')
|
@set('state', 'signed-in')
|
||||||
Travis.trigger('user:signed_in', data.user)
|
Travis.trigger('user:signed_in', data.user)
|
||||||
if router = Travis.__container__.lookup('router:main')
|
if controller = Travis.__container__.lookup('controller:currentUser')
|
||||||
Ember.run.next =>
|
Ember.run.next =>
|
||||||
try
|
try
|
||||||
router.send('afterSignIn')
|
controller.send('afterSignIn')
|
||||||
catch e
|
catch e
|
||||||
throw e unless e =~ /There are no active handlers/ || e =~ /Can't trigger action "afterSignIn/
|
throw e unless e =~ /There are no active handlers/ || e =~ /Can't trigger action "afterSignIn/
|
||||||
@refreshUserData(data.user)
|
@refreshUserData(data.user)
|
||||||
|
|
|
@ -8,16 +8,6 @@ Ember.Router.reopen
|
||||||
@_super(url)
|
@_super(url)
|
||||||
|
|
||||||
Travis.Route = Ember.Route.extend
|
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: ->
|
renderFirstSync: ->
|
||||||
@transitionTo 'first_sync'
|
@transitionTo 'first_sync'
|
||||||
|
|
||||||
|
@ -65,11 +55,13 @@ Travis.ApplicationRoute = Travis.Route.extend
|
||||||
renderFirstSync: ->
|
renderFirstSync: ->
|
||||||
@renderFirstSync()
|
@renderFirstSync()
|
||||||
|
|
||||||
afterSignIn: (path) ->
|
afterSignIn: ->
|
||||||
@afterSignIn(path)
|
if transition = Travis.auth.get('afterSignInTransition')
|
||||||
|
Travis.auth.set('afterSignInTransition', null)
|
||||||
|
transition.retry()
|
||||||
|
|
||||||
afterSignOut: ->
|
afterSignOut: ->
|
||||||
@afterSignOut()
|
@transitionTo('index.current')
|
||||||
|
|
||||||
Travis.Router.reopen
|
Travis.Router.reopen
|
||||||
transitionTo: ->
|
transitionTo: ->
|
||||||
|
@ -377,6 +369,11 @@ Travis.AuthRoute = Travis.Route.extend
|
||||||
deactivate: ->
|
deactivate: ->
|
||||||
@controllerFor('auth').set('redirected', false)
|
@controllerFor('auth').set('redirected', false)
|
||||||
|
|
||||||
|
actions:
|
||||||
|
afterSignIn: ->
|
||||||
|
@transitionTo('index.current')
|
||||||
|
return true
|
||||||
|
|
||||||
Travis.RepoSettingsRoute = Travis.Route.extend
|
Travis.RepoSettingsRoute = Travis.Route.extend
|
||||||
setupController: (controller, model) ->
|
setupController: (controller, model) ->
|
||||||
# TODO: if repo is just a data hash with id and slug load it
|
# TODO: if repo is just a data hash with id and slug load it
|
||||||
|
|
Loading…
Reference in New Issue
Block a user