Skip to content

Commit

Permalink
add tos_agreement and privacy terms on registration
Browse files Browse the repository at this point in the history
tackling GDPR Stuff #13 .
  • Loading branch information
fwolfst committed Sep 22, 2020
1 parent 6d71312 commit 351947c
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ def create
AdminMailer.new_registration(@user).deliver_later
end
end

protected

def sign_up_params
params.require(:user).permit(:email, :password, :password_confirmation, :tos_agreement, :read_privacy_terms)
end
end
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class User < ApplicationRecord

has_many :subscriptions

# GDPR sprinkles
attribute :tos_agreement
validates_acceptance_of :tos_agreement, :allow_nil => false, :on => :create

attribute :read_privacy_terms
validates_acceptance_of :read_privacy_terms, :allow_nil => false, :on => :create

scope :with_current_subscription, -> {
joins(:subscriptions).merge(Subscription.current)
}
Expand Down
6 changes: 6 additions & 0 deletions app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
.field
= f.label :password_confirmation
= f.password_field :password_confirmation, autocomplete: "new-password"
.field
= f.label :tos_agreement
= f.check_box :tos_agreement
.field
= f.label :read_privacy_terms
= f.check_box :read_privacy_terms
.actions
= invisible_captcha :usernote
= f.submit t('register.action'), class: 'button is-primary'
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ de:
name: Video-Name
preview_image: Vorschau-Bild
video: Video-Datei
user:
read_privacy_terms: Stimme AGB zu
tos_agreement: Datenschutzhinweise gelesen
models:
appointment:
labels:
Expand Down
26 changes: 26 additions & 0 deletions doc/knowledgebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* [Video Players](#videoplayers)
* [ffmpeg](#ffmpeg)
+ [Bulma](#bulma)
+ [GDPR](#gdpr)
* [Policy agreements](#policy-agreements)
* [Rights on data](#rights-on-data)
- [ActiveRecord](#activerecord)
- [Licensing](#licensing)
- [Known optimizabilities](#know-optimizabilities)
Expand Down Expand Up @@ -244,6 +247,29 @@ more, like [plyr](https://github.com/sampotts/plyr.)
Nice and mostly responsive (be careful with `levels` and `media` elements).
Custom color-types and shades could be implemented:
https://github.com/jgthms/bulma/issues/2244 (undocumented)
### GDPR

#### Policy agreements

Two separate policies have to be agreed to (technically, one has only to be
taken notice of, there cannot be disagreement by click).

As the policies might change, it is important to store the date of the consents.

In order to force users to agree to the policies, the devises User model is
adjusted to force acceptance via a checkbox. The agreement itself is not stored,
but timestamped instead (column: ).

After a valid login we have to redirect users to re-agree to the terms/policies
if they are outdated. To do so there are at least two general approaches.

#### Rights on data

##### Deletion/anonymisation
Anonymisation will be fine. Make sure to cover the emails as well.

##### Export in machine-readable format
JSON will do.


## ActiveRecord
Expand Down
59 changes: 59 additions & 0 deletions test/system/tos_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: 2020 Felix Wolfsteller
#
# SPDX-License-Identifier: AGPL-3.0-or-later

require "application_system_test_case"
require 'test_helper'

class TosTest < ApplicationSystemTestCase
include Devise::Test::IntegrationHelpers

setup do
Rack::Attack.enabled = false
end

test "to sign up, user has to agree to TOS and have readprivacy statement" do
Rack::Attack.enabled = false

visit new_user_registration_url

fill_in "E-Mail", with: '[email protected]'
fill_in "Passwort", with: '[email protected]'
fill_in "Passwortbestätigung", with: '[email protected]'

click_on "Für Schnupperwoche registrieren"

assert_selector '#error_explanation'

check('Datenschutzhinweise gelesen')

fill_in "Passwort", with: '[email protected]'
fill_in "Passwortbestätigung", with: '[email protected]'

click_on "Für Schnupperwoche registrieren"

assert_selector '#error_explanation'

check('Stimme AGB zu')

fill_in "Passwort", with: '[email protected]'
fill_in "Passwortbestätigung", with: '[email protected]'

click_on "Für Schnupperwoche registrieren"

assert_selector '.notification', text: /Sie erhalten in wenigen Minuten/
end

test "when signed up, dates of consent are saved in User model" do
skip "tbi"
end

test "when logging in and no consent was given, user is forced to agree or delete account" do
skip "tbi"
end

test "admins can update date of tos changes and user has to re-agree or delete account" do
skip "tbi"
end
end

0 comments on commit 351947c

Please sign in to comment.