13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/intercom-app/sessions_concern.rb', line 13
def callback
if response = request.env['omniauth.auth']
app = {
intercom_token: response['credentials']['token'],
intercom_app_id: response['extra']['raw_info']['app']['id_code'],
name: response['extra']['raw_info']['name'],
email: response['extra']['raw_info']['email']
}
app = app.merge(callback_hash.call(session, response)) if callback_hash
session[:intercom] = IntercomApp::SessionRepository.store(app)
session[:intercom_app_id] = app[:intercom_app_id]
IntercomApp::WebhooksManager.new(intercom_token: app[:intercom_token]).create_webhooks_subscriptions if IntercomApp.configuration.webhooks.present?
redirect_to return_address unless IntercomApp.configuration.oauth_modal
else
redirect_to login_url
end
end
|