isaca-rails 0.4.7 → 0.5.1

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: 0dde20172b97d248b8e2e00fb9c46eaf43cea9a6db696ea1b9c417b6ef81f8d2
4
- data.tar.gz: 7a0b3892c71331f8ff528ee72106b5479d59e1656dd7d99556312677bccd68f2
3
+ metadata.gz: a754eb45099830e0ead40a91c429439a7d5d914e1037e870b9a7e550e775da78
4
+ data.tar.gz: 045334643d6a5caf2040600186f2767833c6bceb7449286562a7a9b465da6c74
5
5
  SHA512:
6
- metadata.gz: 8ab36a1da69542c74981be964c30384570c886ade06124a9cda4c7c89da06612c50127988262660e01f4f04f4fc7607a798cd285bdefd9dc2e2a5a19d3f152a6
7
- data.tar.gz: 6708f386489b9c44282c17d29affb64b5a0a42076baaf1412a11fcaee1cba1607464b49e3cd44e826486891546527883ae39129bafb754cee4bba8365eb45cc3
6
+ metadata.gz: c0b74bc7d53bc7b56eb6eb937596cb20bf20986f0b4c084e709038104aee2f5f646c68cafb1c5758bfa97be190fcca4ed9a63b74a6a56dbb37ce18f8760cb334
7
+ data.tar.gz: cb6f501e6792c203942871a3316d36326a86289507b63d7dc581b9087601507f9639bae747ffe3cea18fabd44186fe6191917f1da94039d3338df84af1ccf4de
@@ -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.
@@ -7,8 +7,9 @@ module Isaca
7
7
  helper_method :user_has_privilege?
8
8
  end
9
9
 
10
- def authorize_isaca_user
11
- if current_isaca_user.admin?
10
+ def authorize_isaca_user(user = nil)
11
+ # if current_isaca_user.admin?
12
+ if user.admin?
12
13
  if %w(index new show create update destroy).include?(action_name)
13
14
  if %w(index show).include?(action_name)
14
15
  behavior = 'read'
@@ -24,7 +25,8 @@ module Isaca
24
25
  end
25
26
 
26
27
  privilege = "#{behavior}_#{controller_name.underscore}".to_sym
27
- unless user_has_privilege?(current_isaca_user, privilege)
28
+ # unless user_has_privilege?(current_isaca_user, privilege)
29
+ unless user_has_privilege?(user, privilege)
28
30
  respond_to do |format|
29
31
  message = "#{t('isaca.rails.claims.admin_required')} Missing claim: #{privilege}."
30
32
 
@@ -59,7 +61,7 @@ module Isaca
59
61
  end
60
62
 
61
63
  def user_has_privilege?(user, privilege)
62
- user.claims.select {|c| c.privilege.to_sym == privilege}.any?
64
+ user.claims.where(privilege: privilege).any?
63
65
  end
64
66
 
65
67
  def claim_symbols(claim_params, state)
@@ -1,5 +1,5 @@
1
1
  module Isaca
2
2
  module Rails
3
- VERSION = '0.4.7'
3
+ VERSION = '0.5.1'
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.7
4
+ version: 0.5.1
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-26 00:00:00.000000000 Z
12
+ date: 2021-09-11 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: []