isaca-rails 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +28 -0
  3. data/Rakefile +102 -0
  4. data/app/assets/images/isaca/rails/geometric-1920-blue.png +0 -0
  5. data/app/assets/images/isaca/rails/isaca-logo.png +0 -0
  6. data/app/assets/javascript/isaca/rails/application.js +13 -0
  7. data/app/assets/stylesheets/isaca/rails/all.css +46 -0
  8. data/app/assets/stylesheets/isaca/rails/application.css +15 -0
  9. data/app/assets/stylesheets/isaca/rails/components/button.css +34 -0
  10. data/app/assets/stylesheets/isaca/rails/components/container.css +4 -0
  11. data/app/assets/stylesheets/isaca/rails/components/flash.css +18 -0
  12. data/app/assets/stylesheets/isaca/rails/components/form-control.css +7 -0
  13. data/app/assets/stylesheets/isaca/rails/sessions.css +96 -0
  14. data/app/assets/stylesheets/isaca/rails/user_consent.css +87 -0
  15. data/app/controllers/isaca/rails/application_controller.rb +5 -0
  16. data/app/controllers/isaca/rails/platform/administrators_controller.rb +68 -0
  17. data/app/controllers/isaca/rails/platform/application_controller.rb +10 -0
  18. data/app/controllers/isaca/rails/platform/claims_controller.rb +34 -0
  19. data/app/controllers/isaca/rails/sessions_controller.rb +56 -0
  20. data/app/controllers/isaca/rails/users_consent_controller.rb +24 -0
  21. data/app/controllers/isaca/rails/welcome_controller.rb +3 -0
  22. data/app/helpers/isaca/rails/application_helper.rb +48 -0
  23. data/app/helpers/isaca/rails/claims_helper.rb +13 -0
  24. data/app/models/session/sign_in/form_object.rb +28 -0
  25. data/app/models/user_consent/agreement/form_object.rb +33 -0
  26. data/app/views/isaca/rails/platform/administrators/_administrator.html.erb +6 -0
  27. data/app/views/isaca/rails/platform/administrators/_claims_form.html.erb +9 -0
  28. data/app/views/isaca/rails/platform/administrators/edit.html.erb +9 -0
  29. data/app/views/isaca/rails/platform/administrators/index.html.erb +15 -0
  30. data/app/views/isaca/rails/platform/administrators/new.html.erb +17 -0
  31. data/app/views/isaca/rails/platform/administrators/show.html.erb +29 -0
  32. data/app/views/isaca/rails/sessions/_form.html.erb +15 -0
  33. data/app/views/isaca/rails/sessions/new.html.erb +28 -0
  34. data/app/views/isaca/rails/sessions/shared/_links.html.erb +2 -0
  35. data/app/views/isaca/rails/users_consent/_form.html.erb +50 -0
  36. data/app/views/isaca/rails/users_consent/show.html.erb +21 -0
  37. data/app/views/isaca/rails/welcome/index.html.erb +81 -0
  38. data/app/views/layouts/isaca-rails.html.erb +23 -0
  39. data/config/application.rb +0 -0
  40. data/config/locales/isaca-rails.en.yml +25 -0
  41. data/config/routes.rb +2 -0
  42. data/lib/generators/isaca/rails/install/USAGE +24 -0
  43. data/lib/generators/isaca/rails/install/install_generator.rb +148 -0
  44. data/lib/generators/isaca/rails/install/templates/README +14 -0
  45. data/lib/generators/isaca/rails/install/templates/add_isaca_claims.rb.erb +10 -0
  46. data/lib/generators/isaca/rails/install/templates/add_isaca_to_existing_users.rb.erb +17 -0
  47. data/lib/generators/isaca/rails/install/templates/add_isaca_users.rb.erb +21 -0
  48. data/lib/generators/isaca/rails/install/templates/claim.rb.erb +13 -0
  49. data/lib/generators/isaca/rails/install/templates/isaca-rails.rb +4 -0
  50. data/lib/generators/isaca/rails/install/templates/isaca.rb +5 -0
  51. data/lib/generators/isaca/rails/install/templates/user.rb.erb +3 -0
  52. data/lib/isaca/rails/authentication.rb +166 -0
  53. data/lib/isaca/rails/authorization.rb +51 -0
  54. data/lib/isaca/rails/controller.rb +14 -0
  55. data/lib/isaca/rails/engine.rb +7 -0
  56. data/lib/isaca/rails/user.rb +16 -0
  57. data/lib/isaca/rails/version.rb +5 -0
  58. data/lib/isaca/rails.rb +83 -0
  59. data/lib/tasks/isaca/rails_tasks.rake +4 -0
  60. metadata +297 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4fc58a462bb708f580b405ac03c4887ad998084af7ae3da74ef6838f21248aa1
4
+ data.tar.gz: f87613d180701b22ddd6b97a90f1861ac0a1b1f1a450cffd566f99bd269f9d0d
5
+ SHA512:
6
+ metadata.gz: '09c79205d8fe3382e72be04ea465b09d8058d756b74d43c5e06ec95aa861c474e66d1d8b233bf925a17582e780adc71db58f6764c15d5cb7c242ab463304b02f'
7
+ data.tar.gz: 7c597de660df4b1cbc72db4757d237342db0527024127d7168a5b609aaa2a3f29a8e72feddacbfe975fee1179e5c35ecc689bb3ef56eb1eff244740ff864013f
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Isaca::Rails
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'isaca-rails'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install isaca-rails
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,102 @@
1
+ require 'open3'
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Isaca::Rails'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.md')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
20
+ load 'rails/tasks/engine.rake'
21
+
22
+ load 'rails/tasks/statistics.rake'
23
+
24
+ require 'bundler/gem_tasks'
25
+
26
+ task default: :test
27
+
28
+ task :test_once do
29
+ system "clear" or system "cls"
30
+
31
+ puts "Resetting dummy..."
32
+ Open3.capture2('./script/reset_dummy.sh')
33
+ puts "Finished resetting dummy..."
34
+
35
+ puts "Resetting dummy existing..."
36
+ Open3.capture2('./script/reset_dummy_existing.sh')
37
+ puts "Finished resetting dummy existing..."
38
+
39
+ puts "Resetting dummy integrated..."
40
+ Open3.capture2('./script/reset_dummy_integrated.sh')
41
+ puts "Finished resetting dummy integrated..."
42
+
43
+ test_files = Dir.glob('test/**/*_test.rb')
44
+ test_files.shuffle!
45
+
46
+ test_files.each do |filename|
47
+ cmd = "rake test #{filename}"
48
+ stdout, err = Open3.capture2("rails test #{cmd}")
49
+ puts stdout
50
+ end
51
+ end
52
+
53
+ task :test do
54
+ TEST_ITERATIONS = 10
55
+ SLEEP_TIME = 10
56
+
57
+ while true
58
+ system "clear" or system "cls"
59
+
60
+ puts "Resetting dummy..."
61
+ Open3.capture2('./script/reset_dummy.sh')
62
+ puts "Finished resetting dummy..."
63
+
64
+ puts "Resetting dummy existing..."
65
+ Open3.capture2('./script/reset_dummy_existing.sh')
66
+ puts "Finished resetting dummy existing..."
67
+
68
+ puts "Resetting dummy integrated..."
69
+ Open3.capture2('./script/reset_dummy_integrated.sh')
70
+ puts "Finished resetting dummy integrated..."
71
+
72
+ puts "Dummy applications will be reset after #{TEST_ITERATIONS} test iterations..."
73
+
74
+ cmd = 'rake db:test:prepare'
75
+ stdout, err = Open3.capture2(cmd)
76
+
77
+ (1..TEST_ITERATIONS).each do |n|
78
+ system "clear" or system "cls"
79
+
80
+ test_files = Dir.glob('test/**/*_test.rb')
81
+ test_files.shuffle!
82
+
83
+ test_files.each do |filename|
84
+ cmd = "rake test #{filename}"
85
+
86
+ puts "\n\nRunning command: #{cmd}\n"
87
+ stdout, err = Open3.capture2("rails test #{cmd}")
88
+ puts stdout
89
+ end
90
+
91
+ puts "Sleeping for #{SLEEP_TIME} seconds..."
92
+ puts "Dummy applications will be reset after #{TEST_ITERATIONS-n} more iterations..."
93
+ sleep SLEEP_TIME
94
+ end
95
+ end
96
+ end
97
+
98
+ task :test_file_glob do
99
+ puts "\nTracked test files...\n\n"
100
+ puts Dir.glob('test/**/*_test.rb')
101
+ puts "\n\n"
102
+ end
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,46 @@
1
+ @import url('https://fonts.googleapis.com/css?family=Roboto');
2
+
3
+ body.ir-body, html {
4
+ height: 100%;
5
+ }
6
+
7
+ body.ir-body {
8
+ font-family: 'Roboto', sans-serif;
9
+ margin: 0;
10
+ color: rgb(75,75,75);
11
+
12
+ background-image: url(/assets/isaca/rails/geometric-1920-blue.png);
13
+ background-position: center;
14
+ background-repeat: no-repeat;
15
+ background-size: cover;
16
+ background-attachment: fixed;
17
+ }
18
+
19
+
20
+ /* Custom, iPhone Retina */
21
+ @media only screen and (min-width : 320px) {
22
+
23
+ }
24
+
25
+ /* Extra Small Devices, Phones */
26
+ @media only screen and (min-width : 480px) {
27
+
28
+ }
29
+
30
+ /* Small Devices, Tablets */
31
+ @media only screen and (min-width : 768px) {
32
+ body.ir-body {
33
+ background-image: none;
34
+ }
35
+
36
+ }
37
+
38
+ /* Medium Devices, Desktops */
39
+ @media only screen and (min-width : 992px) {
40
+
41
+ }
42
+
43
+ /* Large Devices, Wide Screens */
44
+ @media only screen and (min-width : 1200px) {
45
+
46
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree
14
+ *= require_self
15
+ */
@@ -0,0 +1,34 @@
1
+ .ir-btn {
2
+ border: none;
3
+ box-shadow: 0px 3px 2px rgba(0,0,0,0.9);
4
+ }
5
+
6
+ .ir-btn:hover {
7
+ cursor: pointer;
8
+ }
9
+
10
+ .ir-btn-primary {
11
+ color: white;
12
+ background-color: rgb(164,31,74);
13
+ box-shadow: 0px 3px 2px rgba(77, 0, 38, 0.9);
14
+ }
15
+
16
+ .ir-btn-primary:hover {
17
+ background-color: rgb(104, 0, 43);
18
+ }
19
+
20
+ input[type=submit].ir-btn-primary:disabled {
21
+ cursor: inherit;
22
+ background-color: rgba(164, 31, 74, 0.25);
23
+ box-shadow: 0px 3px 2px rgba(77, 0, 38, 0.39);
24
+ }
25
+
26
+ input[type=submit].ir-form-control {
27
+ width: 100%;
28
+ }
29
+
30
+ input[type=submit].ir-btn-lg {
31
+ padding: 20px;
32
+ font-size: 1.2em;
33
+ }
34
+
@@ -0,0 +1,4 @@
1
+ .ir-container {
2
+ width: 100%;
3
+ padding: 15px;
4
+ }
@@ -0,0 +1,18 @@
1
+ .ir-flash {
2
+ border: 1px solid #c9c9c9;
3
+ background-color: #eaeaea;
4
+ padding: 5px;
5
+ margin: 10px 0;
6
+ }
7
+
8
+ .ir-flash.ir-flash-alert {
9
+ background-color: #f7b4b4;
10
+ border-color: #d27474;
11
+ color: #eb4242;
12
+ }
13
+
14
+ .ir-flash.ir-flash-notice {
15
+ background-color: #a9ddf7;
16
+ border-color: #32aeec;
17
+ color: #0d5e87;
18
+ }
@@ -0,0 +1,7 @@
1
+ input.ir-form-control,
2
+ input.ir-form-control[role=button] {
3
+ display: block;
4
+ width: 99%;
5
+ margin-bottom: 15px;
6
+ font-size: 1.2em;
7
+ }
@@ -0,0 +1,96 @@
1
+ .ir-login-container {
2
+ display: flex;
3
+ height: 100%;
4
+ }
5
+
6
+ .ir-login-container > main {
7
+ width: 100%;
8
+ background-image: url(/assets/isaca/rails/geometric-1920-blue.png);
9
+ background-position: center;
10
+ background-repeat: no-repeat;
11
+ background-size: cover;
12
+ }
13
+
14
+ .ir-login-container > main > .ir-brand {
15
+ background-color: white;
16
+ padding-top: 20px;
17
+ padding-bottom: 20px;
18
+ border-bottom: 1px solid rgb(75,75,75);
19
+ }
20
+
21
+ .ir-login-container > main > .ir-brand > a > img {
22
+ height: 50px;
23
+ display: block;
24
+ margin: 0 auto;
25
+ }
26
+
27
+ .ir-login-container > aside {
28
+ display: none;
29
+ }
30
+
31
+ .ir-login-container > main > .ir-form-body {
32
+ padding: 20px;
33
+ background-color: white;
34
+ margin: 10px;
35
+ margin-top: 20px;
36
+ box-shadow: 0 3px 3px rgba(0,0,0,0.3);
37
+ }
38
+
39
+ ul.ir-shared-links {
40
+ list-style: none;
41
+ padding-left: 0;
42
+ }
43
+
44
+ /* Custom, iPhone Retina */
45
+ @media only screen and (min-width : 320px) {
46
+
47
+ }
48
+
49
+ /* Extra Small Devices, Phones */
50
+ @media only screen and (min-width : 480px) {
51
+
52
+ }
53
+
54
+ /* Small Devices, Tablets */
55
+ @media only screen and (min-width : 768px) {
56
+ .ir-login-container > main > .ir-brand {
57
+ border-bottom-color: transparent;
58
+ }
59
+
60
+ .ir-login-container > main > .ir-form-body {
61
+ background-color: transparent;
62
+ box-shadow: none;
63
+ }
64
+
65
+ .ir-login-container > main {
66
+ flex: 5;
67
+ background-color: #fafafa;
68
+ background-image: none;
69
+ border-right: 1px solid rgb(75,75,75);
70
+ }
71
+
72
+ .ir-login-container > aside {
73
+ display: inherit;
74
+ background-image: url(/assets/isaca/rails/geometric-1920-blue.png);
75
+ background-position: center;
76
+ background-repeat: no-repeat;
77
+ background-size: cover;
78
+ flex: 7;
79
+ }
80
+ }
81
+
82
+ /* Medium Devices, Desktops */
83
+ @media only screen and (min-width : 992px) {
84
+
85
+ }
86
+
87
+ /* Large Devices, Wide Screens */
88
+ @media only screen and (min-width : 1200px) {
89
+ .ir-login-container > main {
90
+ flex: 3;
91
+ }
92
+
93
+ .ir-login-container > aside {
94
+ flex: 9;
95
+ }
96
+ }
@@ -0,0 +1,87 @@
1
+ .ir-consent-container {
2
+ display: flex;
3
+ }
4
+
5
+ .ir-consent-container > main > .ir-brand {
6
+ background-color: white;
7
+ padding-top: 20px;
8
+ padding-bottom: 20px;
9
+ border-bottom: 1px solid rgb(75,75,75);
10
+ }
11
+
12
+ .ir-consent-container > main > .ir-brand > a > img {
13
+ height: 50px;
14
+ display: block;
15
+ margin: 0 auto;
16
+ }
17
+
18
+ .ir-consent-container > main > .ir-form-body {
19
+ padding: 20px;
20
+ background-color: white;
21
+ margin: 10px;
22
+ margin-top: 20px;
23
+ box-shadow: 0 3px 3px rgba(0,0,0,0.3);
24
+ }
25
+
26
+ /* Custom, iPhone Retina */
27
+ @media only screen and (min-width : 320px) {
28
+
29
+ }
30
+
31
+ /* Extra Small Devices, Phones */
32
+ @media only screen and (min-width : 480px) {
33
+
34
+ }
35
+
36
+ /* Small Devices, Tablets */
37
+ @media only screen and (min-width : 768px) {
38
+ .ir-consent-container {
39
+ height: 100%;
40
+ }
41
+
42
+ .ir-consent-container > main > .ir-brand {
43
+ border-bottom-color: transparent;
44
+ }
45
+
46
+ .ir-consent-container > main > .ir-brand > img {
47
+ height: 50px;
48
+ }
49
+
50
+ .ir-consent-container > main {
51
+ flex: 9;
52
+ background-color: #fafafa;
53
+ background-image: none;
54
+ border-left: 1px solid rgb(75,75,75);
55
+ height: 100%;
56
+ }
57
+
58
+ .ir-consent-container > aside {
59
+ display: inherit;
60
+ background-image: url(/assets/isaca/rails/geometric-1920-blue.png);
61
+ background-position: center;
62
+ background-repeat: no-repeat;
63
+ background-size: cover;
64
+ flex: 3;
65
+ }
66
+
67
+ .ir-consent-container > main > .ir-form-body {
68
+ background-color: transparent;
69
+ box-shadow: none;
70
+ }
71
+ }
72
+
73
+ /* Medium Devices, Desktops */
74
+ @media only screen and (min-width : 992px) {
75
+
76
+ }
77
+
78
+ /* Large Devices, Wide Screens */
79
+ @media only screen and (min-width : 1200px) {
80
+ .ir-consent-container > main {
81
+ flex: 5;
82
+ }
83
+
84
+ .ir-consent-container > aside {
85
+ flex: 7;
86
+ }
87
+ }
@@ -0,0 +1,5 @@
1
+ class Isaca::Rails::ApplicationController < ActionController::Base
2
+ include Isaca::Rails::Controller
3
+
4
+ layout 'isaca-rails'
5
+ end
@@ -0,0 +1,68 @@
1
+ module Isaca
2
+ module Rails
3
+ module Platform
4
+ class AdministratorsController < ApplicationController
5
+ def index
6
+ @administrators = Isaca::Rails.configuration.user_model.where(admin: true)
7
+ end
8
+
9
+ def edit
10
+ @administrator = Isaca::Rails.configuration.user_model.find(params[:id])
11
+ end
12
+
13
+ def show
14
+ @administrator = Isaca::Rails.configuration.user_model.find(params[:id])
15
+ end
16
+
17
+ def create
18
+ administrator = Isaca::Rails.configuration.user_model.find_by_email(administrator_params[:email])
19
+
20
+ if administrator
21
+ administrator.update_attribute(:admin, true)
22
+
23
+ respond_to do |format|
24
+ format.js
25
+ format.html do
26
+ redirect_to administrator_path(administrator), notice: t('isaca.rails.administrators.created')
27
+ end
28
+ end
29
+ else
30
+ respond_to do |format|
31
+ format.js
32
+ format.html do
33
+ redirect_to new_administrator_path, alert: "#{t('isaca.rails.administrators.email_not_found')} #{administrator_params[:email]}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ administrator = Isaca::Rails.configuration.user_model.find(params[:id])
41
+
42
+ if administrator
43
+ administrator.update_attribute(:admin, false)
44
+ administrator.claims.destroy_all
45
+
46
+ respond_to do |format|
47
+ format.js
48
+ format.html do
49
+ redirect_to administrators_path, notice: t('isaca.rails.administrators.deleted')
50
+ end
51
+ end
52
+ else
53
+ respond_to do |format|
54
+ format.js
55
+ format.html do
56
+ redirect_to administrators_path, alert: t('isaca.rails.administrators.administrator_not_found')
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ def administrator_params
63
+ params.require(:administrator).permit(:email)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,10 @@
1
+ module Isaca
2
+ module Rails
3
+ module Platform
4
+ class ApplicationController < Isaca::Rails::ApplicationController
5
+ before_action :authenticate_isaca_user
6
+ before_action :authorize_isaca_user
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ module Isaca
2
+ module Rails
3
+ module Platform
4
+ class ClaimsController < ApplicationController
5
+ def create
6
+ @administrator = Isaca::Rails.configuration.user_model.find(params[:administrator_id])
7
+
8
+ # Destroy claims that exist but need to be removed
9
+ @administrator.claims.where(privilege: claim_symbols(claim_params, :destroyable)).destroy_all
10
+
11
+ # Create claims that do not exist but need to be created
12
+ claim_symbols(claim_params, :creatable).each do |claim|
13
+ @administrator.claims.create(privilege: claim) unless user_has_privilege?(@administrator, claim)
14
+ end
15
+
16
+ @administrator.reload
17
+
18
+ respond_to do |format|
19
+ format.js
20
+ format.html do
21
+ redirect_to administrator_path(@administrator), notice: t('isaca.rails.claims.updated')
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def claim_params
29
+ params.require(:claims).permit(::Claim.privileges.keys.collect(&:to_sym))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,56 @@
1
+ class Isaca::Rails::SessionsController < Isaca::Rails::ApplicationController
2
+ def new
3
+ @form_object = Session::SignIn::FormObject.new
4
+ end
5
+
6
+ def create
7
+ begin
8
+ authenticate(sign_in_params[:username], sign_in_params[:password])
9
+
10
+ respond_to do |format|
11
+ format.html do
12
+ flash.notice = t('isaca.rails.sessions.sign_in_success')
13
+ redirect_after_sign_in_or root_path
14
+ end
15
+
16
+ format.json do
17
+ render json: current_isaca_user.to_json
18
+ end
19
+ end
20
+ rescue Isaca::ServiceError => e
21
+ respond_to do |format|
22
+ format.html do
23
+ flash.alert = e.message
24
+ redirect_to sign_in_path
25
+ end
26
+
27
+ format.json do
28
+ render json: { error: e.message }
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ isaca_sign_out
37
+
38
+ respond_to do |format|
39
+ format.html do
40
+ flash.notice = t('isaca.rails.sessions.sign_out_success')
41
+ redirect_to root_path
42
+ end
43
+
44
+ format.json do
45
+ head :ok
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ private
52
+
53
+ def sign_in_params
54
+ params.require(:sign_in).permit(:username, :password)
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ class Isaca::Rails::UsersConsentController < Isaca::Rails::ApplicationController
2
+ before_action :authenticate_isaca_user
3
+
4
+ def show
5
+ @form_object = UserConsent::Agreement::FormObject.new
6
+ end
7
+
8
+ def create
9
+ @form_object = UserConsent::Agreement::FormObject.new(agreement_params)
10
+
11
+ if @form_object.report_consent(current_isaca_user.imis_id)
12
+ flash.notice = t('isaca.rails.user_consent.consent_submitted')
13
+ redirect_after_sign_in_or(root_path)
14
+ else
15
+ render :show
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def agreement_params
22
+ params.require(:agreements).permit(:marketing_policy, :privacy_policy)
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ class Isaca::Rails::WelcomeController < Isaca::Rails::ApplicationController
2
+
3
+ end