36 lines
647 B
Ruby
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
|