codecombat/app/views/admin_view.coffee

37 lines
953 B
CoffeeScript
Raw Normal View History

2014-02-26 17:14:43 -05:00
{backboneFailure, genericFailure} = require 'lib/errors'
2014-01-03 13:32:13 -05:00
View = require 'views/kinds/RootView'
template = require 'templates/admin'
2014-02-26 17:14:43 -05:00
storage = require 'lib/storage'
2014-01-03 13:32:13 -05:00
module.exports = class AdminView extends View
id: "admin-view"
template: template
2014-02-26 17:14:43 -05:00
events:
'click #enter-espionage-mode': 'enterEspionageMode'
enterEspionageMode: ->
userEmail = $("#user-email").val().toLowerCase()
username = $("#user-username").val().toLowerCase()
userIdentifier = userEmail || username
postData =
usernameLower: username
emailLower: userEmail
$.ajax
type: "POST",
url: "/auth/spy"
data: postData
success: @espionageSuccess
error: @espionageFailure
espionageSuccess: (model) ->
storage.save('whoami',model)
window.location.reload()
2014-03-15 10:11:00 -04:00
2014-02-26 17:14:43 -05:00
espionageFailure: (jqxhr, status,error)->
console.log "There was an error entering espionage mode: #{error}"
2014-03-15 10:11:00 -04:00