Skip to content

Commit

Permalink
Add /logout route, enable logout for CodePlay
Browse files Browse the repository at this point in the history
  • Loading branch information
sderickson committed Mar 20, 2017
1 parent cc85c2b commit 7266e92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/core/Router.coffee
Expand Up @@ -139,6 +139,8 @@ module.exports = class CocoRouter extends Backbone.Router
'il-signup': go('account/IsraelSignupView')

'legal': go('LegalView')

'logout': 'logout'

'play(/)': go('play/CampaignView', { redirectStudents: true, redirectTeachers: true }) # extra slash is to get Facebook app to work
'play/ladder/:levelID/:leagueType/:leagueID': go('ladder/LadderView')
Expand Down Expand Up @@ -352,3 +354,7 @@ module.exports = class CocoRouter extends Backbone.Router

reload: ->
document.location.reload()

logout: ->
me.logout()
@navigate('/', { trigger: true })
3 changes: 1 addition & 2 deletions app/models/User.coffee
Expand Up @@ -277,12 +277,11 @@ module.exports = class User extends CocoModel
@fetch(options)

logout: (options={}) ->
return if features.codePlay
options.type = 'POST'
options.url = '/auth/logout'
FB?.logout?()
options.success ?= ->
location = _.result(currentView, 'logoutRedirectURL')
location = _.result(window.currentView, 'logoutRedirectURL')
if location
window.location = location
else
Expand Down

0 comments on commit 7266e92

Please sign in to comment.