Class: Clickwrap::WithdrawalsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/clickwrap/withdrawals_controller.rb

Overview

Withdrawing one consent purpose.

This screen is deliberately as short as the screen that granted the consent in the first place: one page, one control, one press. Withdrawal must be no harder than granting was — no support ticket, no email, no re-authentication the grant did not require, no confirmation maze. A gem that made taking consent back harder than giving it would be building the exact pattern it exists to prevent, so this controller has nothing in it but the two actions.

Withdrawal APPENDS an event. It never deletes or edits the historical grant: what was true then stays recorded, and what is true now is that the person changed their mind. Only consent is withdrawable — withdrawing future processing does not rewrite a past agreement or a factual declaration.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Clickwrap::ApplicationController

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/clickwrap/withdrawals_controller.rb', line 24

def create
  Clickwrap.withdraw!(
    @purpose_key,
    actor: clickwrap_current_actor,
    tenant: clickwrap_current_tenant,
    http_request: request,
    because: t("clickwrap.withdrawals.recorded_reason")
  )

  redirect_to @return_to, allow_other_host: false, notice: t("clickwrap.withdrawals.confirmed")
rescue AlreadyWithdrawnError
  # Pressing the button twice is not an error worth showing a person. The
  # purpose is withdrawn either way, which is what they asked for.
  redirect_to @return_to, allow_other_host: false, notice: t("clickwrap.withdrawals.already_withdrawn")
rescue NotWithdrawableError => error
  flash.now[:alert] = error.message
  render :new, status: 422
end

#newObject



22
# File 'app/controllers/clickwrap/withdrawals_controller.rb', line 22

def new; end