Class: Spree::Telegram::BaseController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Spree::Telegram::BaseController
show all
- Defined in:
- app/controllers/spree/telegram/base_controller.rb
Instance Method Summary
collapse
Instance Method Details
#authorized_vendors ⇒ Object
25
26
27
|
# File 'app/controllers/spree/telegram/base_controller.rb', line 25
def authorized_vendors
@authorized_vendors ||= authorizer_context.user.vendors
end
|
#authorizer_context ⇒ Object
29
30
31
32
33
34
|
# File 'app/controllers/spree/telegram/base_controller.rb', line 29
def authorizer_context
@authorizer_context ||= ::SpreeCmCommissioner::TelegramWebAppVendorUserAuthorizer.call(
telegram_init_data: params[:telegram_init_data],
bot_token: ENV.fetch('DEFAULT_TELEGRAM_BOT_API_TOKEN', nil)
)
end
|
#handle_unauthorized_vendor ⇒ Object
21
22
23
|
# File 'app/controllers/spree/telegram/base_controller.rb', line 21
def handle_unauthorized_vendor
redirect_to telegram_forbidden_url
end
|
#required_telegram_vendor_user! ⇒ Object
12
13
14
15
|
# File 'app/controllers/spree/telegram/base_controller.rb', line 12
def required_telegram_vendor_user!
raise SpreeCmCommissioner::UnauthorizedVendorError if params[:telegram_init_data].blank?
raise SpreeCmCommissioner::UnauthorizedVendorError unless authorizer_context.success?
end
|
#resource_not_found ⇒ Object
17
18
19
|
# File 'app/controllers/spree/telegram/base_controller.rb', line 17
def resource_not_found
redirect_to telegram_resource_not_found_url
end
|