Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

646 B
Raw Blame
class Api::V1::Accounts::Tiktok::AuthorizationsController < Api::V1::Accounts::OauthAuthorizationController
  include Tiktok::IntegrationHelper

  before_action :ensure_tiktok_enabled

  def create
    redirect_url = Tiktok::AuthClient.authorize_url(
      state: generate_tiktok_token(Current.account.id, params[:return_to])
    )

    if redirect_url
      render json: { success: true, url: redirect_url }
    else
      render json: { success: false }, status: :unprocessable_entity
    end
  end

  private

  def ensure_tiktok_enabled
    raise Pundit::NotAuthorizedError unless Current.account.feature_enabled?('channel_tiktok')
  end
end