Skip to content

Instantly share code, notes, and snippets.

@lukegalea
Forked from trianglegrrl/gist:6543387
Last active December 22, 2015 22:59
Show Gist options
  • Save lukegalea/6543410 to your computer and use it in GitHub Desktop.
Save lukegalea/6543410 to your computer and use it in GitHub Desktop.
CoachApp.IndexRoute = Ember.Route.extend
model: (params) ->
client_id = localStorage.getItem 'clientId'
localStorage.removeItem('clientId')
if CoachApp.get('token')? and client_id? and !isNaN(client_id, 10)
CoachApp.Client.findById client_id
afterModel: (client) ->
if client
@transitionTo 'client', client
else if CoachApp.get('token')?
@transitionTo 'clients'
else
# Do nothing!! Let's just render the instructions page
renderTemplate: -> @render if Env.testing 'jasmine' else 'index'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment