prey / gdpr_rails

Rails Engine for the GDPR compliance
https://preyproject.com
MIT License
626 stars 62 forks source link

How to store cookie consent ? #11

Closed EtienneDepaulis closed 6 years ago

EtienneDepaulis commented 6 years ago

The method explaine in the readme does not seem to work (or even exist):

@user.store_policy_cookie if cookies["policy_rule_cookie"] == "accepted"

I had to do something like this to make it work:

class ApplicationController < ActionController::Base

  protected

  def after_sign_in_path_for(user)
    handle_cookie_policy_for(user) if cookies["cookieconsent_status"] == "dismiss"

    super(user)
  end

  def handle_cookie_policy_for(user)
    rule_name = "cookie"

    return if !user.needs_policy_confirmation_for?(rule_name)

    term = user.policy_term_on(rule_name)
    user.handle_policy_for(term).accept!
  end
end

Should the Readme be updated or is it me not using correctly this method ? Thanks for your help

patriciojofre commented 6 years ago

Hi @EtienneDepaulis

We forget to include this in the engine. our apologies. You can implement the following in your User model

def store_policy_cookie
  term = PolicyManager::Config.rules.find{|o| o.name == "cookieconsent_status"}.terms.last
  user_term = self.handle_policy_for(term)
  user_term.accept! unless user_term.accepted?
end

Pato

michelson commented 6 years ago

We will include this ASAP! Thanks for reporting

El mar., 8 de may. de 2018 1:14 p. m., Pato Jofre notifications@github.com escribió:

Hi @EtienneDepaulis https://github.com/EtienneDepaulis

We forget to include this in the engine. our apologies. You can implement the following in your model

def store_policy_cookie term = PolicyManager::Config.rules.find{|o| o.name == "cookieconsent_status"}.terms.last user_term = self.handle_policy_for(term) user_term.accept! unless user_term.accepted?end

Pato

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/prey/gdpr_rails/issues/11#issuecomment-387457538, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAuyG2TwzNzvGwQeynGnpQb-I0FO89Uks5twcRcgaJpZM4T23Am .

michelson commented 6 years ago

check version 0.3.0 ! this includes this change and more.

best!