2019-08-14 09:48:44 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
include DeviseTokenAuth::Concerns::SetUserByToken
|
2021-09-14 06:25:02 +00:00
|
|
|
include RequestExceptionHandler
|
2022-06-13 14:48:38 +00:00
|
|
|
include Pundit::Authorization
|
2020-11-30 10:54:54 +00:00
|
|
|
include SwitchLocale
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-07-14 13:10:24 +00:00
|
|
|
skip_before_action :verify_authenticity_token
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
before_action :set_current_user, unless: :devise_controller?
|
2020-11-30 10:54:54 +00:00
|
|
|
around_action :switch_locale
|
2019-08-14 09:48:44 +00:00
|
|
|
around_action :handle_with_exception, unless: :devise_controller?
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_current_user
|
|
|
|
@user ||= current_user
|
|
|
|
Current.user = @user
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_subscription
|
2020-06-07 08:28:05 +00:00
|
|
|
@subscription ||= Current.account.subscription
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
|
2020-05-26 17:08:48 +00:00
|
|
|
def pundit_user
|
|
|
|
{
|
|
|
|
user: Current.user,
|
|
|
|
account: Current.account,
|
|
|
|
account_user: Current.account_user
|
|
|
|
}
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|