Files
chatwoot/app/controllers/oauth_callback_controller.rb
T
2024-05-31 18:49:22 +05:30

36 lines
647 B
Ruby

class OauthCallbackController < ApplicationController
def show
@response = oauth_client.auth_code.get_token(
oauth_code,
redirect_uri: "#{base_url}/#{provider_name}/callback"
)
handle_response
rescue StandardError => e
ChatwootExceptionTracker.new(e).capture_exception
redirect_to '/'
end
private
def provider_name
raise NotImplementedError
end
def oauth_client
raise NotImplementedError
end
def oauth_code
params[:code]
end
def base_url
ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
end
def parsed_body
@parsed_body ||= @response.response.parsed
end
end