clear-sessions.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. return $http({
  24. method: 'POST',
  25. url: '/user/sessions/clear',
  26. headers: { 'X-CSRF-Token': window.csrfToken },
  27. })
  28. .then(function () {
  29. $scope.state.otherSessions = []
  30. $scope.state.error = false
  31. return ($scope.state.success = true)
  32. })
  33. .catch(() => ($scope.state.error = true))
  34. })
  35. }
  36. )