summaryrefslogtreecommitdiff
path: root/app/controllers/jira_connect/events_controller.rb
blob: 8f79c82d8472ec997e07730c5598b33d45f5b4be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class JiraConnect::EventsController < JiraConnect::ApplicationController
  skip_before_action :verify_atlassian_jwt!, only: :installed
  before_action :verify_qsh_claim!, only: :uninstalled

  def installed
    installation = JiraConnectInstallation.new(install_params)

    if installation.save
      head :ok
    else
      head :unprocessable_entity
    end
  end

  def uninstalled
    if current_jira_installation.destroy
      head :ok
    else
      head :unprocessable_entity
    end
  end

  private

  def install_params
    params.permit(:clientKey, :sharedSecret, :baseUrl).transform_keys(&:underscore)
  end
end