Guest User

Untitled

a guest
Oct 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. diff --git a/security/Security.php b/security/Security.php
  2. index ec99a6c..205b9a0 100644
  3. --- a/security/Security.php
  4. +++ b/security/Security.php
  5. @@ -158,6 +158,8 @@ class Security extends Controller {
  6. * to log in.
  7. */
  8. static function permissionFailure($controller = null, $messageSet = null) {
  9. + self::set_ignore_disallowed_actions(true);
  10. +
  11. if(!$controller) $controller = Controller::curr();
  12.  
  13. if(Director::is_ajax()) {
  14. @@ -864,4 +866,18 @@ class Security extends Controller {
  15. return self::$default_login_dest;
  16. }
  17.  
  18. + protected static $ignore_disallowed_actions = false;
  19. +
  20. + /**
  21. + * Set to true to ignore access to disallowed actions, rather than returning permission failure
  22. + * Note that this is just a flag that other code needs to check with Security::ignore_disallowed_actions()
  23. + * @param $flag True or false
  24. + */
  25. + public static function set_ignore_disallowed_actions($flag) {
  26. + self::$ignore_disallowed_actions = $flag;
  27. + }
  28. + public static function ignore_disallowed_actions() {
  29. + return self::$ignore_disallowed_actions;
  30. + }
  31. +
  32. }
  33. diff --git a/view/SSViewer.php b/view/SSViewer.php
  34. index 23b1f4e..70215db 100644
  35. --- a/view/SSViewer.php
  36. +++ b/view/SSViewer.php
  37. @@ -612,7 +612,9 @@ class SSViewer {
  38. if(Director::isDev() || Director::is_cli() || Permission::check('ADMIN')) {
  39. self::flush_template_cache();
  40. } else {
  41. - return Security::permissionFailure(null, 'Please log in as an administrator to flush the template cache.');
  42. + if(!Security::ignore_disallowed_actions()) {
  43. + return Security::permissionFailure(null, 'Please log in as an administrator to flush the template cache.');
  44. + }
  45. }
  46. }
Add Comment
Please, Sign In to add comment