 
 CurrentUserActions = flux.createActions [
   'setToken'  # (token) ->
-  'loadAllCourses'
-  'loadedAllCourses'
   'loadName'
   'loadedName'
   'logout'    # () ->    # API Hooks onto this action and transitions

    @_isAdmin = results.is_admin
    @emitChange()

  loadAllCourses: -> # Used by API
  loadedAllCourses: (results) ->
    # {items} = results # TODO: This JSON format is inconsistent with the paged results
    items = results
    @_courses = _.map items, (course) ->
      {id} = course
      CourseActions.loaded(course, id)
      id # Just store the ids in @_courses

    @emitChange()

  reset: ->
    @_token = null
    @_name = 'Guest'
    @_courses = null

  exports:
    getToken: -> @_token
    getCSRFToken: -> CSRF_Token
    isCoursesLoaded: -> !!@_courses
    getName: -> @_name
    isAdmin: -> @_isAdmin

    getCourseRole: (courseId) ->
      @_getCourseRole(courseId)

    getCourses: ->
      _.map @_courses, (id) ->
        CourseStore.get(id)

    getDashboardRoute: (courseId) ->
      menuRole = @_getCourseRole(courseId)

CurrentUserStore = flux.createStore
  actions: [
    CurrentUserActions.setToken
    CurrentUserActions.loadName
    CurrentUserActions.loadedName
    CurrentUserActions.reset
  ]

  _token: null

  _getRouteByRole: (routeType, menuRole) ->
    ROUTES[routeType].roles[menuRole] or ROUTES[routeType].roles.default
