Class: Decidim::NewslettersOptInController

Inherits:
ApplicationController show all
Includes:
FormFactory
Defined in:
decidim-core/app/controllers/decidim/newsletters_opt_in_controller.rb

Overview

The controller to control newsletter Opt-in for GDPR

Instance Method Summary collapse

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#updateObject



10
11
12
13
14
15
16
17
18
19
20
# File 'decidim-core/app/controllers/decidim/newsletters_opt_in_controller.rb', line 10

def update
  enforce_permission_to(:update, :user, current_user:)

  current_user.newsletter_opt_in_validate
  if current_user.save
    flash[:notice] = t(".success")
  else
    flash[:alert] = t(".error")
  end
  redirect_to decidim.root_path(host: current_organization)
end