diff options
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 333082f68..84dc516fc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,6 +126,16 @@ class ApplicationController < ActionController::Base @theme = resolve_pack(Themes.instance.flavour(current_flavour), pack_name, current_skin) end + def _monsterfork_api + return :basic if current_user.nil? + return current_user.monsterfork_api.to_sym unless doorkeeper_token && doorkeeper_token.application.present? + app = doorkeeper_token.application.name.downcase.strip.gsub(/ +/, '_').gsub(/[^\w.-]/, '') + return :vanilla if ENV.fetch('MONSTERFORK_API_FORCE_VANILLA', '').downcase.split.include?(app) + return :basic if ENV.fetch('MONSTERFORK_API_FORCE_BASIC', '').downcase.split.include?(app) + return :full if ENV.fetch('MONSTERFORK_API_FORCE_FULL', '').downcase.split.include?(app) + current_user.monsterfork_api.to_sym + end + protected def truthy_param?(key) @@ -230,4 +240,8 @@ class ApplicationController < ActionController::Base def mark_cacheable! expires_in 0, public: true end + + def monsterfork_api + @monsterfork_api ||= _monsterfork_api + end end |