isaca-rails 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7207131060a5c23b082caef1af6e6189638b4a7fed5092c39d3ef6a3928d4ae5
4
- data.tar.gz: 3057cfea6dce1ec4c083e9e81cd5a67d12be8cb53edbb7ca1779bf4e0b40e4ca
3
+ metadata.gz: 90c702697899fa3268bb9f7e7b9520b40fd5d3b7effd2ed3de3b8626cb44bb4d
4
+ data.tar.gz: 799f89cdc87027c6330c3cb2a07545e6ea18068bcd7be37661c70afb1774e4bc
5
5
  SHA512:
6
- metadata.gz: 6e9f19c73ad8bc73ec5044b1d7a6bbf976858a1b3c0b5345432d92d5a593b517001c45cc73aa13dcfeb05f8b37d0ff997cb1cc48edea37fe258c0c132c29d0f2
7
- data.tar.gz: c153bcf2826ba59aa15d6c06485bd03ccc139a199eefa5897134603de3df0c5a0dd2213097f4f9f39b7ea7f9ed91e25e17122a0e0b553b407f0843f1761ade36
6
+ metadata.gz: 0a5961e510658f1922bbbe6dba3a0c58a6c83b8f045a6b605b66c36e5f4f17003087861ac58a7928dd892f6379acc930fb7733c8d8c42a57f359aacbe68c7522
7
+ data.tar.gz: 1c4efa1deb6a46bec6c88ff47bab3aceca1a19915f5fc33ac4eef6fd194cc1d5df720250a6e4a73480a0abd61cd760faf9749d0731a2da98232cb32a73446044
@@ -8,8 +8,17 @@ class Isaca::Rails::UsersConsentController < Isaca::Rails::ApplicationController
8
8
  def create
9
9
  @form_object = UserConsent::Agreement::FormObject.new(agreement_params)
10
10
 
11
- if @form_object.report_consent(current_isaca_user.imis_id)
12
- flash.notice = t('isaca.rails.user_consent.consent_submitted')
11
+ if @form_object.valid?
12
+ response = Isaca::Request::ReportConsent.get(current_isaca_user.imis_id, current_isaca_user.email, {
13
+ marketing: agreement_params[:marketing_policy]
14
+ })
15
+
16
+ if response
17
+ flash.notice = t('isaca.rails.user_consent.consent_submitted')
18
+ else
19
+ flash.alert = t('isaca.rails.user_consent.consent_failed')
20
+ end
21
+
13
22
  redirect_after_sign_in_or(root_path)
14
23
  else
15
24
  render :show
@@ -1,25 +1,11 @@
1
1
  module UserConsent
2
2
  module Agreement
3
- # Form object used for handling user consent
4
3
  class FormObject
5
4
  include ActiveModel::Model
6
5
 
7
6
  attr_accessor :privacy_policy, :marketing_policy
8
- validates_acceptance_of :privacy_policy, allow_nil: false
9
- validates_presence_of :marketing_policy
10
-
11
-
12
- # Method used to report user consent of the privacy policy and marketing
13
- #
14
- # @param options [Hash] Optional. If not provided, marketing consent will default to NO [0].
15
- #
16
- # == Options
17
- # [marketing] Consent for marketing. Acceptable values are 0 [for NO] and 1 [for YES].
18
- #
19
- # @return [Boolean] Whether or not the consent was successfully reported to ISACA
20
- def report_consent(imis_id, options={})
21
- Isaca::Request::ReportConsent.get(imis_id, options).success? if valid?
22
- end
7
+ validates :privacy_policy, acceptance: {accept: %w(0 1)}, allow_nil: false
8
+ validates :marketing_policy, acceptance: {accept: %w(0 1)}, allow_nil: false
23
9
 
24
10
  # Defining this method allows us to use some ActiveModel patterns. For example, forms will be identified
25
11
  # as sign_in instead of session_sign_in_form_object.
@@ -6,7 +6,7 @@
6
6
  <%= f.check_box :privacy_policy %>
7
7
 
8
8
  ISACA has changed their privacy notice, to access the revised notice and terms,
9
- <a href="https://www.isaca.org/pages/Privacy.aspx" target="_blank">click here</a>.
9
+ <a href="https://www.isaca.org/pages/Privacy.aspx" target="_blank">click here</a> and this Platform's Terms of Use <a href="/terms_of_use" target="_blank">click here</a>.
10
10
 
11
11
  By continuing to use the site you agree to the revised terms.
12
12
  </label>
@@ -14,6 +14,7 @@ en:
14
14
  user_consent:
15
15
  consent_required: Your consent is required before proceeding.
16
16
  consent_submitted: You have successfully updated your privacy policy and marketing preferences.
17
+ consent_failed: An error occurred that prevented you from submitting your consent form.
17
18
  administrators:
18
19
  email_not_found: Could not find a record with the provided email.
19
20
  created: Administrator was successfully created.
@@ -160,14 +160,8 @@ module Isaca
160
160
  klass = Isaca::Rails.configuration.user_model
161
161
 
162
162
  # Fetch the first record with a matching imis id or initialize a new record with the given user data.
163
- @current_isaca_user = klass.create_with(attributes).find_or_initialize_by(imis_id: isaca_user.imis_id)
164
-
165
- # Update the old user record or save a new user record
166
- if @current_isaca_user.new_record?
167
- @current_isaca_user.save
168
- else
169
- @current_isaca_user.update_attributes(attributes)
170
- end
163
+ @current_isaca_user = klass.where(imis_id: isaca_user.imis_id).first_or_initialize
164
+ @current_isaca_user.update_attributes(attributes)
171
165
 
172
166
  # Temporal data so we do not need dedicated columns for this but we do need to associate it with the user
173
167
  @current_isaca_user.privacy = isaca_user.privacy
@@ -59,7 +59,7 @@ module Isaca
59
59
  end
60
60
 
61
61
  def user_has_privilege?(user, privilege)
62
- user.claims.select {|c| c.privilege.to_sym == privilege}.any?
62
+ user.claims.where(privilege: privilege).any?
63
63
  end
64
64
 
65
65
  def claim_symbols(claim_params, state)
@@ -4,7 +4,7 @@ module Isaca
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- attr_accessor :privacy, :marketing, :country
7
+ attr_accessor :privacy, :marketing
8
8
 
9
9
  has_many :claims
10
10
 
@@ -1,5 +1,5 @@
1
1
  module Isaca
2
2
  module Rails
3
- VERSION = '0.4.6'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isaca-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Orahood
8
- autorequire:
8
+ - Shaun Eutsey
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
12
+ date: 2021-09-08 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
@@ -30,14 +31,14 @@ dependencies:
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '1.3'
34
+ version: '1.4'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '1.3'
41
+ version: '1.4'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: sass-rails
43
44
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +224,7 @@ dependencies:
223
224
  description: Description of Isaca::Rails.
224
225
  email:
225
226
  - morahood@gmail.com
227
+ - seutsey@isaca.org
226
228
  executables: []
227
229
  extensions: []
228
230
  extra_rdoc_files: []
@@ -285,10 +287,10 @@ files:
285
287
  - lib/isaca/rails/user.rb
286
288
  - lib/isaca/rails/version.rb
287
289
  - lib/tasks/isaca/rails_tasks.rake
288
- homepage:
290
+ homepage:
289
291
  licenses: []
290
292
  metadata: {}
291
- post_install_message:
293
+ post_install_message:
292
294
  rdoc_options: []
293
295
  require_paths:
294
296
  - lib
@@ -303,9 +305,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
305
  - !ruby/object:Gem::Version
304
306
  version: '0'
305
307
  requirements: []
306
- rubyforge_project:
307
- rubygems_version: 2.7.7
308
- signing_key:
308
+ rubygems_version: 3.2.27
309
+ signing_key:
309
310
  specification_version: 4
310
311
  summary: Summary of Isaca::Rails.
311
312
  test_files: []