travis-web/assets/scripts/app/controllers/current_user.coffee
Piotr Sarnacki 3544d523d7 Refactor auth code
* don't use __container__
* register it as a factory on container and inject into routes and
  controller
* avoid afterSignIn errors by checking on hooksTarget, ApplicationRoute
  should register itself as a hooksTarget
* keep user info on auth
2014-05-28 10:22:47 +02:00

20 lines
572 B
CoffeeScript

delegate = (name, options) ->
options ||= options
->
target = @get(options.to)
target[name].apply(target, arguments)
Travis.CurrentUserController = Em.ObjectController.extend
sync: ->
@get('content').sync()
content: (->
@get('auth.currentUser')
).property('auth.currentUser')
syncingDidChange: (->
if (user = @get('content')) && user.get('isSyncing') && !user.get('syncedAt')
Ember.run.scheduleOnce 'routerTransitions', this, ->
@container.lookup('router:main').send('renderFirstSync')
).observes('isSyncing', 'content')