Created
October 18, 2019 06:08
-
-
Save stp-che/f26a42850c0596ae075deaa38bfa2066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtraChargeGroundsController < WithSessionController | |
require_global_permission Access::P_EXTRA_CHARGE_MANAGE | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WithSessionController < ApplicationController | |
class << self | |
private | |
def require_global_permission(permission, **opts) | |
before_action :forbid!, **opts, unless: ->{ | |
CurrentSession.context_by_permission(permission)[Access::Context::GLOBAL] | |
} | |
end | |
end | |
private | |
def forbid! | |
raise ForbiddenError | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment