clear-sessions.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. import App from '../base'
  13. import getMeta from '../utils/meta'
  14. export default App.controller('ClearSessionsController', function(
  15. $scope,
  16. $http
  17. ) {
  18. $scope.state = {
  19. otherSessions: getMeta('ol-otherSessions'),
  20. error: false,
  21. success: false
  22. }
  23. return ($scope.clearSessions = function() {
  24. console.log('>> clearing all sessions')
  25. return $http({
  26. method: 'POST',
  27. url: '/user/sessions/clear',
  28. headers: { 'X-CSRF-Token': window.csrfToken }
  29. })
  30. .then(function() {
  31. $scope.state.otherSessions = []
  32. $scope.state.error = false
  33. return ($scope.state.success = true)
  34. })
  35. .catch(() => ($scope.state.error = true))
  36. })
  37. })