clear-sessions.js 1.1 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(
  15. 'ClearSessionsController',
  16. function ($scope, $http) {
  17. $scope.state = {
  18. otherSessions: getMeta('ol-otherSessions'),
  19. error: false,
  20. success: false,
  21. }
  22. return ($scope.clearSessions = function () {
  23. console.log('>> clearing all sessions')
  24. return $http({
  25. method: 'POST',
  26. url: '/user/sessions/clear',
  27. headers: { 'X-CSRF-Token': window.csrfToken },
  28. })
  29. .then(function () {
  30. $scope.state.otherSessions = []
  31. $scope.state.error = false
  32. return ($scope.state.success = true)
  33. })
  34. .catch(() => ($scope.state.error = true))
  35. })
  36. }
  37. )