rails_base 0.51.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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +32 -0
- data/Rakefile +32 -0
- data/app/assets/config/rails_base/manifest.js +3 -0
- data/app/assets/images/rails_base/favicon.ico +0 -0
- data/app/assets/javascripts/rails_base/admin.js +2 -0
- data/app/assets/javascripts/rails_base/application.js +22 -0
- data/app/assets/javascripts/rails_base/cable.js +13 -0
- data/app/assets/javascripts/rails_base/mfa_auth.coffee +3 -0
- data/app/assets/javascripts/rails_base/secondary_authentication.coffee +3 -0
- data/app/assets/javascripts/rails_base/sessions.js +152 -0
- data/app/assets/javascripts/rails_base/user_settings.coffee +3 -0
- data/app/assets/stylesheets/rails_base/admin.css +4 -0
- data/app/assets/stylesheets/rails_base/application.scss +15 -0
- data/app/assets/stylesheets/rails_base/mfa_auth.scss +3 -0
- data/app/assets/stylesheets/rails_base/scaffolds.scss +84 -0
- data/app/assets/stylesheets/rails_base/secondary_authentication.scss +3 -0
- data/app/assets/stylesheets/rails_base/user_settings.scss +3 -0
- data/app/controllers/rails_base/admin_controller.rb +315 -0
- data/app/controllers/rails_base/application_controller.rb +153 -0
- data/app/controllers/rails_base/errors_controller.rb +29 -0
- data/app/controllers/rails_base/mfa_auth_controller.rb +50 -0
- data/app/controllers/rails_base/secondary_authentication_controller.rb +224 -0
- data/app/controllers/rails_base/switch_user_controller.rb +29 -0
- data/app/controllers/rails_base/user_settings_controller.rb +81 -0
- data/app/controllers/rails_base/users/passwords_controller.rb +19 -0
- data/app/controllers/rails_base/users/registrations_controller.rb +80 -0
- data/app/controllers/rails_base/users/sessions_controller.rb +108 -0
- data/app/helpers/rails_base/admin_helper.rb +107 -0
- data/app/helpers/rails_base/appearance_helper.rb +58 -0
- data/app/helpers/rails_base/application_helper.rb +26 -0
- data/app/helpers/rails_base/capture_reference_helper.rb +57 -0
- data/app/helpers/rails_base/mfa_auth_helper.rb +2 -0
- data/app/helpers/rails_base/secondary_authentication_helper.rb +2 -0
- data/app/helpers/rails_base/user_field_validators.rb +108 -0
- data/app/helpers/rails_base/user_settings_helper.rb +22 -0
- data/app/jobs/rails_base/application_job.rb +10 -0
- data/app/jobs/twilio_job.rb +9 -0
- data/app/mailers/rails_base/application_mailer.rb +9 -0
- data/app/mailers/rails_base/email_verification_mailer.rb +22 -0
- data/app/mailers/rails_base/event_mailer.rb +16 -0
- data/app/models/admin_action.rb +119 -0
- data/app/models/rails_base/application_record.rb +22 -0
- data/app/models/rails_base/user_constants.rb +28 -0
- data/app/models/secret.rb +37 -0
- data/app/models/short_lived_data.rb +132 -0
- data/app/models/user.rb +143 -0
- data/app/services/rails_base/admin_risky_mfa_send.rb +80 -0
- data/app/services/rails_base/admin_update_attribute.rb +100 -0
- data/app/services/rails_base/authentication/authenticate_user.rb +28 -0
- data/app/services/rails_base/authentication/constants.rb +60 -0
- data/app/services/rails_base/authentication/decision_twofa_type.rb +76 -0
- data/app/services/rails_base/authentication/destroy_user.rb +45 -0
- data/app/services/rails_base/authentication/mfa_set_encrypt_token.rb +32 -0
- data/app/services/rails_base/authentication/mfa_validator.rb +88 -0
- data/app/services/rails_base/authentication/modify_password.rb +67 -0
- data/app/services/rails_base/authentication/send_forgot_password.rb +26 -0
- data/app/services/rails_base/authentication/send_login_mfa_to_user.rb +77 -0
- data/app/services/rails_base/authentication/send_verification_email.rb +103 -0
- data/app/services/rails_base/authentication/session_token_verifier.rb +31 -0
- data/app/services/rails_base/authentication/single_sign_on_create.rb +44 -0
- data/app/services/rails_base/authentication/single_sign_on_send.rb +101 -0
- data/app/services/rails_base/authentication/single_sign_on_verify.rb +42 -0
- data/app/services/rails_base/authentication/sso_verify_email.rb +43 -0
- data/app/services/rails_base/authentication/update_phone_send_verification.rb +46 -0
- data/app/services/rails_base/authentication/verify_forgot_password.rb +46 -0
- data/app/services/rails_base/email_change.rb +20 -0
- data/app/services/rails_base/encryption.rb +87 -0
- data/app/services/rails_base/name_change.rb +71 -0
- data/app/services/rails_base/service_base.rb +65 -0
- data/app/services/rails_base/service_logging.rb +23 -0
- data/app/views/layouts/rails_base/application.html.erb +185 -0
- data/app/views/layouts/rails_base/mailer.html.erb +13 -0
- data/app/views/layouts/rails_base/mailer.text.erb +1 -0
- data/app/views/new.html.erb +4 -0
- data/app/views/rails_base/admin/history.html.erb +26 -0
- data/app/views/rails_base/admin/index.html.erb +149 -0
- data/app/views/rails_base/admin/show_config.html.erb +18 -0
- data/app/views/rails_base/devise/confirmations/new.html.erb +16 -0
- data/app/views/rails_base/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/rails_base/devise/mailer/email_changed.html.erb +7 -0
- data/app/views/rails_base/devise/mailer/password_change.html.erb +3 -0
- data/app/views/rails_base/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/rails_base/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/rails_base/devise/passwords/edit.html.erb +25 -0
- data/app/views/rails_base/devise/passwords/new.html.erb +27 -0
- data/app/views/rails_base/devise/registrations/edit.html.erb +43 -0
- data/app/views/rails_base/devise/registrations/new.html.erb +123 -0
- data/app/views/rails_base/devise/sessions/new.html.erb +4 -0
- data/app/views/rails_base/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/rails_base/devise/shared/_links.html.erb +25 -0
- data/app/views/rails_base/devise/unlocks/new.html.erb +16 -0
- data/app/views/rails_base/email_verification_mailer/email_verification.html.erb +25 -0
- data/app/views/rails_base/email_verification_mailer/event.html.erb +20 -0
- data/app/views/rails_base/email_verification_mailer/forgot_password.html.erb +22 -0
- data/app/views/rails_base/errors/internal_error.html.erb +1 -0
- data/app/views/rails_base/errors/not_found.html.erb +1 -0
- data/app/views/rails_base/errors/unacceptable.html.erb +1 -0
- data/app/views/rails_base/event_mailer/event.html.erb +10 -0
- data/app/views/rails_base/mfa_auth/mfa_code.html.erb +10 -0
- data/app/views/rails_base/secondary_authentication/after_email_login_session_new.html.erb +3 -0
- data/app/views/rails_base/secondary_authentication/forgot_password.html.erb +9 -0
- data/app/views/rails_base/secondary_authentication/remove_me.html.erb +1 -0
- data/app/views/rails_base/secondary_authentication/static.html.erb +5 -0
- data/app/views/rails_base/shared/_admin_actions_modal.html.erb +65 -0
- data/app/views/rails_base/shared/_admin_config_class.html.erb +52 -0
- data/app/views/rails_base/shared/_admin_history.html.erb +86 -0
- data/app/views/rails_base/shared/_admin_modify_email.html.erb +78 -0
- data/app/views/rails_base/shared/_admin_modify_name.html.erb +107 -0
- data/app/views/rails_base/shared/_admin_modify_phone.html.erb +87 -0
- data/app/views/rails_base/shared/_admin_modify_text.html.erb +35 -0
- data/app/views/rails_base/shared/_admin_risky_change.html.erb +57 -0
- data/app/views/rails_base/shared/_admin_risky_mfa.html.erb +74 -0
- data/app/views/rails_base/shared/_admin_selector_dropdown.html.erb +70 -0
- data/app/views/rails_base/shared/_admin_toggle_button.html.erb +72 -0
- data/app/views/rails_base/shared/_admin_warning_alert.html.erb +7 -0
- data/app/views/rails_base/shared/_appearance_mode_selector.html.erb +183 -0
- data/app/views/rails_base/shared/_custom_form_validation_javascript.html.erb +129 -0
- data/app/views/rails_base/shared/_enable_mfa_auth_modal.html.erb +105 -0
- data/app/views/rails_base/shared/_error_pages.html.erb +123 -0
- data/app/views/rails_base/shared/_logged_in_header.html.erb +123 -0
- data/app/views/rails_base/shared/_logged_out_header.html.erb +14 -0
- data/app/views/rails_base/shared/_mfa_input_layout.html.erb +5 -0
- data/app/views/rails_base/shared/_mfa_input_layout_default.html.erb +97 -0
- data/app/views/rails_base/shared/_mfa_input_layout_fallback.html.erb +55 -0
- data/app/views/rails_base/shared/_modify_mfa_auth_modal.html.erb +20 -0
- data/app/views/rails_base/shared/_password_confirm_javascript.html.erb +71 -0
- data/app/views/rails_base/shared/_reset_password_form.html.erb +111 -0
- data/app/views/rails_base/shared/_session_create_form.html.erb +32 -0
- data/app/views/rails_base/shared/_session_timeout_modal.html.erb +76 -0
- data/app/views/rails_base/switch_user/_widget.html.erb +5 -0
- data/app/views/rails_base/user_settings/_confirm_destroy_user.html.erb +42 -0
- data/app/views/rails_base/user_settings/_destroy_user.html.erb +106 -0
- data/app/views/rails_base/user_settings/_modify_name.html.erb +71 -0
- data/app/views/rails_base/user_settings/_modify_password.html.erb +101 -0
- data/app/views/rails_base/user_settings/_modify_password_update_password.html.erb +2 -0
- data/app/views/rails_base/user_settings/index.html.erb +54 -0
- data/config/initializers/01_rails_config.rb +19 -0
- data/config/initializers/admin_action_helper.rb +88 -0
- data/config/initializers/browser.rb +4 -0
- data/config/initializers/default_logged_in_headers.rb +23 -0
- data/config/initializers/devise.rb +314 -0
- data/config/initializers/encryption.rb +2 -0
- data/config/initializers/switch_user.rb +58 -0
- data/config/initializers/switch_user_helper.rb +29 -0
- data/config/locales/devise.en.yml +65 -0
- data/config/locales/en.yml +58 -0
- data/config/routes.rb +114 -0
- data/db/migrate/20210212175453_devise_create_rails_base_users.rb +56 -0
- data/db/migrate/20210212190537_create_rails_base_short_lived_data.rb +19 -0
- data/db/migrate/20210212192645_create_rails_base_secrets.rb +11 -0
- data/db/migrate/20210406015744_create_rails_base_admin_actions.rb +17 -0
- data/db/seeds.rb +23 -0
- data/lib/link_decision_helper.rb +71 -0
- data/lib/rails_base.rb +50 -0
- data/lib/rails_base/admin/action_cache.rb +99 -0
- data/lib/rails_base/admin/action_helper.rb +134 -0
- data/lib/rails_base/admin/default_index_tile.rb +176 -0
- data/lib/rails_base/admin/index_tile.rb +186 -0
- data/lib/rails_base/config.rb +52 -0
- data/lib/rails_base/configuration/active_job.rb +38 -0
- data/lib/rails_base/configuration/admin.rb +231 -0
- data/lib/rails_base/configuration/app.rb +52 -0
- data/lib/rails_base/configuration/appearance.rb +131 -0
- data/lib/rails_base/configuration/authentication.rb +37 -0
- data/lib/rails_base/configuration/base.rb +209 -0
- data/lib/rails_base/configuration/display/background_color.rb +25 -0
- data/lib/rails_base/configuration/display/btn_danger.rb +25 -0
- data/lib/rails_base/configuration/display/btn_dark.rb +25 -0
- data/lib/rails_base/configuration/display/btn_info.rb +25 -0
- data/lib/rails_base/configuration/display/btn_light.rb +25 -0
- data/lib/rails_base/configuration/display/btn_primary.rb +25 -0
- data/lib/rails_base/configuration/display/btn_secondary.rb +25 -0
- data/lib/rails_base/configuration/display/btn_success.rb +25 -0
- data/lib/rails_base/configuration/display/btn_warning.rb +25 -0
- data/lib/rails_base/configuration/display/footer.rb +54 -0
- data/lib/rails_base/configuration/display/navbar.rb +25 -0
- data/lib/rails_base/configuration/display/table_body.rb +25 -0
- data/lib/rails_base/configuration/display/table_header.rb +25 -0
- data/lib/rails_base/configuration/display/text.rb +26 -0
- data/lib/rails_base/configuration/exceptions_app.rb +25 -0
- data/lib/rails_base/configuration/login_behavior.rb +17 -0
- data/lib/rails_base/configuration/mailer.rb +116 -0
- data/lib/rails_base/configuration/mfa.rb +84 -0
- data/lib/rails_base/configuration/owner.rb +17 -0
- data/lib/rails_base/configuration/redis.rb +29 -0
- data/lib/rails_base/configuration/user.rb +43 -0
- data/lib/rails_base/engine.rb +51 -0
- data/lib/rails_base/version.rb +10 -0
- data/lib/tasks/rails_base_tasks.rake +4 -0
- data/lib/twilio_helper.rb +26 -0
- data/lib/velocity_limiter.rb +91 -0
- metadata +619 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
|
2
|
+
<% modal_prepend = "admin_#{modal_id}" %>
|
3
|
+
|
4
|
+
<div class="modal fade" id='<%= modal_id %>' tabindex="-1" role="dialog" aria-labelledby="example_'<%= modal_id %>'" aria-hidden="true">
|
5
|
+
<div class="modal-dialog modal-lg" role="document">
|
6
|
+
<div class="modal-content">
|
7
|
+
<div class="modal-header">
|
8
|
+
<h5 class="modal-title" id="exampleModalLabel">Modify Name</h5>
|
9
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
10
|
+
<span aria-hidden="true">×</span>
|
11
|
+
</button>
|
12
|
+
</div>
|
13
|
+
<div class="modal-body" style="text-align: center;">
|
14
|
+
<h4>Please enter the name you would like to change to</h4>
|
15
|
+
<div class="col-auto">
|
16
|
+
<label class="sr-only" for="inlineFormInputGroup">Full Name</label>
|
17
|
+
<div class="input-group mb-2">
|
18
|
+
<div class="input-group-prepend">
|
19
|
+
<div class="input-group-text">First Name</div>
|
20
|
+
</div>
|
21
|
+
<input type="text" class="form-control" id="<%= modal_prepend %>_first_name" placeholder="<%= user.first_name %>">
|
22
|
+
<div class="invalid-feedback">
|
23
|
+
<%= "Invalid Characters present in first name" %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div class="col-auto">
|
28
|
+
<label class="sr-only" for="inlineFormInputGroup">Full Name</label>
|
29
|
+
<div class="input-group mb-2">
|
30
|
+
<div class="input-group-prepend">
|
31
|
+
<div class="input-group-text">Last Name</div>
|
32
|
+
</div>
|
33
|
+
<input type="text" class="form-control" id="<%= modal_prepend %>_last_name" placeholder="<%= user.last_name %>">
|
34
|
+
<div class="invalid-feedback">
|
35
|
+
<%= "Invalid Characters present in last name" %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div class="col-auto my-1">
|
40
|
+
<button id='<%= modal_prepend %>' class="btn btn_success">Submit</button>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
<div class="modal-footer">
|
44
|
+
<button type="button" class="mr-auto btn btn_secondary" data-dismiss="modal">Close</button>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<%
|
51
|
+
values = [
|
52
|
+
{ name: "##{modal_prepend}_first_name", criteria: { required: true, min_length: 2, max_length: 25, pattern: :name }},
|
53
|
+
{ name: "##{modal_prepend}_last_name", criteria: { required: true, min_length: 2 , max_length: 25, pattern: :name }},
|
54
|
+
]
|
55
|
+
function_name = modal_id
|
56
|
+
submit_method = "#{modal_id}_#{(10*5*rand).to_i}"
|
57
|
+
%>
|
58
|
+
|
59
|
+
<%= render partial: 'rails_base/shared/custom_form_validation_javascript', locals: { function_name: function_name, values: values } %>
|
60
|
+
|
61
|
+
<script type="text/javascript">
|
62
|
+
$('#<%= modal_id %>').appendTo('body');
|
63
|
+
|
64
|
+
$('#<%= modal_id %>').on('shown.bs.modal', function (e) {
|
65
|
+
$('#<%= modal_prepend %>_first_name').removeClass('is-invalid')
|
66
|
+
$('#<%= modal_prepend %>_last_name').removeClass('is-invalid')
|
67
|
+
$('#<%= modal_prepend %>_first_name').focus();
|
68
|
+
});
|
69
|
+
|
70
|
+
$('#<%= modal_id %>').on('hidden.bs.modal', function (e) {
|
71
|
+
// make sure to remove invalid field if present
|
72
|
+
$('#<%= modal_prepend %>_first_name').removeClass('is-invalid')
|
73
|
+
$('#<%= modal_prepend %>_last_name').removeClass('is-invalid')
|
74
|
+
// clear values
|
75
|
+
$('#<%= modal_prepend %>_first_name').val('');
|
76
|
+
$('#<%= modal_prepend %>_last_name').val('');
|
77
|
+
})
|
78
|
+
|
79
|
+
function <%= submit_method %>(){
|
80
|
+
var first = $('#<%= modal_prepend %>_first_name').val()
|
81
|
+
var last = $('#<%= modal_prepend %>_last_name').val()
|
82
|
+
var data = { 'first_name': first, 'last_name': last, 'id': '<%= user.id%>' }
|
83
|
+
console.table(data)
|
84
|
+
$.ajax({
|
85
|
+
type: "POST",
|
86
|
+
url: "<%= RailsBase.url_routes.admin_upate_name_path%>",
|
87
|
+
headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') },
|
88
|
+
dataType: 'json',
|
89
|
+
data: data,
|
90
|
+
success: function(data) {
|
91
|
+
$('#<%= modal_id %>').modal('hide')
|
92
|
+
$('#<%= text %>').text(data.full_name)
|
93
|
+
_rails_base_display_success(data.message)
|
94
|
+
},
|
95
|
+
error: function(xhr, status, error) {
|
96
|
+
$('#<%= modal_id %>').modal('hide')
|
97
|
+
_rails_base_display_alert(xhr.responseJSON.message)
|
98
|
+
}
|
99
|
+
})
|
100
|
+
}
|
101
|
+
|
102
|
+
$('#<%= modal_prepend %>').click(function( event ) {
|
103
|
+
if (<%=function_name%>() == true){
|
104
|
+
<%= submit_method %>()
|
105
|
+
}
|
106
|
+
});
|
107
|
+
</script>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<div class="modal-dialog modal-lg" role="document">
|
2
|
+
<div class="modal-content">
|
3
|
+
<div class="modal-header">
|
4
|
+
<div class="modal-header text-center">
|
5
|
+
<h4 class="col-12 modal-title text-center" id="exampleModalLabel">
|
6
|
+
!¡ Risky Change Warning !¡
|
7
|
+
</h4>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="modal-body" style="text-align: center;">
|
11
|
+
<h4>Modify Phone for <%= user.full_name %>:</h4>
|
12
|
+
<div class="col-auto">
|
13
|
+
<label class="sr-only" for="inlineFormInputGroup">Phone</label>
|
14
|
+
<div class="form-row phone_number_input_stage justify-content-center">
|
15
|
+
<div class="modal_phone_number_input">
|
16
|
+
<div class="input-group input-group-lg mx-auto">
|
17
|
+
<div class="input-group-prepend">
|
18
|
+
<span class="input-group-text">
|
19
|
+
US Phone Number
|
20
|
+
</span>
|
21
|
+
</div>
|
22
|
+
<%= phone_field_tag('phone_number', nil, style: "font-size:25px;", class: 'phone_us', maxlength: 14, size: 15)%>
|
23
|
+
<div class="invalid-feedback">
|
24
|
+
<%= "Phone number must be a valid US phone number" %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<div class="col-auto my-1">
|
31
|
+
<button id='modify_phone_submit' class="btn btn_success">Submit</button>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<div class="modal-footer">
|
35
|
+
<button type="button" class="mr-auto btn btn_secondary" data-dismiss="modal">Close</button>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
<script type="text/javascript">
|
43
|
+
$('.phone_us').mask('(000) 000-0000', {placeholder: '(___) ___-____'});
|
44
|
+
|
45
|
+
function submit_phone_number(){
|
46
|
+
var phone = $('#phone_number').val()
|
47
|
+
var data = { 'phone_number': phone, 'id': '<%= user.id%>'}
|
48
|
+
console.table(data)
|
49
|
+
$.ajax({
|
50
|
+
type: "POST",
|
51
|
+
url: "<%= RailsBase.url_routes.admin_upate_phone_path%>",
|
52
|
+
headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') },
|
53
|
+
dataType: 'json',
|
54
|
+
data: data,
|
55
|
+
success: function(data) {
|
56
|
+
hide_shared_admin_modal();
|
57
|
+
console.log(`modify_id: #<%= modify_id %>`)
|
58
|
+
console.log(`phone: ${data.attribute}`)
|
59
|
+
$('#<%= modify_id %>').text(data.attribute)
|
60
|
+
_rails_base_display_success(data.message)
|
61
|
+
},
|
62
|
+
error: function(xhr, status, error) {
|
63
|
+
hide_shared_admin_modal();
|
64
|
+
_rails_base_display_alert(xhr.responseJSON.message)
|
65
|
+
}
|
66
|
+
})
|
67
|
+
}
|
68
|
+
|
69
|
+
function validate_submission(){
|
70
|
+
if ($('#phone_number').val().length == 14){
|
71
|
+
$('#phone_number').removeClass('is-invalid')
|
72
|
+
submit_phone_number();
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
$('#phone_number').addClass('is-invalid')
|
76
|
+
}
|
77
|
+
|
78
|
+
$('#modify_phone_submit').keypress(function(e){
|
79
|
+
if(e.which == 13) {
|
80
|
+
validate_submission();
|
81
|
+
}
|
82
|
+
})
|
83
|
+
|
84
|
+
$('#modify_phone_submit').click(function( event ) {
|
85
|
+
validate_submission();
|
86
|
+
});
|
87
|
+
</script>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<% text_id = "#{type}_#{user.id}_#{(10**10*rand).to_i}" %>
|
2
|
+
<% span_id = "#{text_id}_span" %>
|
3
|
+
<% modal_id = "#{text_id}_modal" %>
|
4
|
+
|
5
|
+
<% if disable_action %>
|
6
|
+
<div>
|
7
|
+
<span style="width: 88%; float: left;">
|
8
|
+
<%= current_value %>
|
9
|
+
</span>
|
10
|
+
<span style="width: 8%; float: right;">
|
11
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-question-circle" viewBox="0 0 16 16" data-toggle='tooltip' title='<%= disable_msg %> '>
|
12
|
+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
13
|
+
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
|
14
|
+
</svg>
|
15
|
+
</span>
|
16
|
+
</div>
|
17
|
+
<% else %>
|
18
|
+
<p style="text-align:left;">
|
19
|
+
<span id='<%= text_id %>'> <%= current_value %> </span>
|
20
|
+
<span id='<%= span_id %>' style="float:right;">
|
21
|
+
<button style='border:none;, background: transparent;'>
|
22
|
+
✎
|
23
|
+
</button>
|
24
|
+
</span>
|
25
|
+
</p>
|
26
|
+
|
27
|
+
<%= render partial: modal_partial, locals: { modal_id: modal_id, user: user, parent: "#{parent}_#{type}", text: text_id } %>
|
28
|
+
|
29
|
+
|
30
|
+
<script type="text/javascript">
|
31
|
+
$('#<%= span_id %>').click(function() {
|
32
|
+
$('#<%= modal_id %>').modal('show');
|
33
|
+
});
|
34
|
+
</script>
|
35
|
+
<% end %>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<% text_id = "#{type}_#{user.id}_#{(10**15*rand).to_i}" %>
|
2
|
+
<% span_id = "#{text_id}_span" %>
|
3
|
+
<% risky_modal_id = "#{text_id}_risky_modal" %>
|
4
|
+
<% partial_modal = "#{text_id}_partial_modal" %>
|
5
|
+
|
6
|
+
<% if disable_action %>
|
7
|
+
<span style="width: 88%; float: left;">
|
8
|
+
<%= current_value %>
|
9
|
+
</span>
|
10
|
+
<span style="width: 8%; float: right;">
|
11
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-question-circle" viewBox="0 0 16 16" data-toggle='tooltip' title='<%= disable_msg %> '>
|
12
|
+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
13
|
+
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
|
14
|
+
</svg>
|
15
|
+
</span>
|
16
|
+
</div>
|
17
|
+
<% else %>
|
18
|
+
<p style="text-align:left;">
|
19
|
+
<span id='<%= text_id %>'> <%= current_value %> </span>
|
20
|
+
<span id='<%= span_id %>' style="float:right;">
|
21
|
+
<button class='risky-icon-og' style='border:none;, background: transparent;'>
|
22
|
+
✎
|
23
|
+
</button>
|
24
|
+
<span class="risky-icon-mask spinner-border spinner-border-sm" role="status" aria-hidden="true" style="display: none">
|
25
|
+
</span>
|
26
|
+
</span>
|
27
|
+
</p>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="modal fade" id='<%= risky_modal_id %>' tabindex="-1" role="dialog" aria-labelledby="example_'<%= risky_modal_id %>'" aria-hidden="true">
|
31
|
+
<div class="modal-dialog modal-lg" role="document">
|
32
|
+
<div class="modal-content">
|
33
|
+
<div class="modal-header text-center">
|
34
|
+
<h4 class="col-12 modal-title text-center" id="exampleModalLabel">
|
35
|
+
!¡ Risky Change Warning !¡
|
36
|
+
</h4>
|
37
|
+
</div>
|
38
|
+
<div class="modal-body" style="text-align: center;">
|
39
|
+
<h5>You are about to modify a users <%= type %>. You must 2fa!</h5>
|
40
|
+
<%= render partial: 'rails_base/shared/admin_risky_mfa', locals: { modal_id: risky_modal_id, user: user, parent: "#{parent}_#{type}", text: text_id, next_modal: partial_modal, modal_mapping: modal_mapping, modify_id: text_id } %>
|
41
|
+
</div>
|
42
|
+
<div class="modal-footer">
|
43
|
+
<button type="button" class="mr-auto btn btn_secondary" data-dismiss="modal">Close</button>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<script type="text/javascript">
|
50
|
+
$('#<%= risky_modal_id %>').appendTo('body');
|
51
|
+
|
52
|
+
$('#<%= span_id %>').click(function() {
|
53
|
+
admin_risky_icon_wait() // Disable double clicking and sending multiple mfas
|
54
|
+
admin_risky_mfa_send('<%= risky_modal_id %>')
|
55
|
+
});
|
56
|
+
</script>
|
57
|
+
<% end %>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<% mfa_id = "mfa_#{modal_id}_mfa_input" %>
|
2
|
+
<% mfa_id_submit = "mfa_#{modal_id}_mfa_input_submit" %>
|
3
|
+
|
4
|
+
<div class="form-group text-center">
|
5
|
+
<div class="text-center" style="font-size: 25px">
|
6
|
+
Please enter the MFA code you received at <%= admin_user.phone_number %>
|
7
|
+
</div>
|
8
|
+
<div class='row justify-content-center' style="font-size: 25px;">
|
9
|
+
<div class="col-xs-2">
|
10
|
+
<%= text_field_tag mfa_id, nil, maxlength: RailsBase::Authentication::Constants::MFA_LENGTH, class: 'text-center form-control numbersOnly digit', autofocus: true, type: "tel", style: "font-size:25px;" %>
|
11
|
+
<div class="invalid-feedback">
|
12
|
+
2FA code must be <%= RailsBase::Authentication::Constants::MFA_LENGTH %> numbers
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
<div class="text-center">
|
18
|
+
<button id='<%= mfa_id_submit %>' class="btn btn_success" type="submit" style='width:50%;'>Submit</button>
|
19
|
+
<button class="btn btn_info btn-block" id='<%= mfa_id_submit %>_spinner' type="button" disabled style="display: none">
|
20
|
+
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true">
|
21
|
+
</span>
|
22
|
+
Hang tight
|
23
|
+
</button>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<%
|
27
|
+
length = RailsBase::Authentication::Constants::MFA_LENGTH
|
28
|
+
values = [
|
29
|
+
{ name: "##{mfa_id}", criteria: { required: true, min_length: length, max_length: length, pattern: :numeric, enforce_blur: false }},
|
30
|
+
|
31
|
+
]
|
32
|
+
function_name = mfa_id
|
33
|
+
submit_method = "#{mfa_id}_#{(10*5*rand).to_i}"
|
34
|
+
%>
|
35
|
+
|
36
|
+
<%= render partial: 'rails_base/shared/custom_form_validation_javascript', locals: { function_name: function_name, values: values } %>
|
37
|
+
|
38
|
+
<script type="text/javascript">
|
39
|
+
$('#<%= modal_id %>').on('shown.bs.modal', function(){
|
40
|
+
$('#<%= mfa_id %>').focus();
|
41
|
+
});
|
42
|
+
|
43
|
+
function <%= modal_id %>_toggle(value){
|
44
|
+
if(value=='show'){
|
45
|
+
$('#<%= mfa_id %>').val('');
|
46
|
+
$('#<%= mfa_id_submit %>').show();
|
47
|
+
$('#<%= mfa_id_submit %>_spinner').hide();
|
48
|
+
} else {
|
49
|
+
$('#<%= mfa_id_submit %>').hide();
|
50
|
+
$('#<%= mfa_id_submit %>_spinner').show();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
$('#<%= mfa_id_submit %>').click(function( event ) {
|
55
|
+
console.log($('#<%= mfa_id %>').val())
|
56
|
+
var length_match = $('#<%= mfa_id %>').val().length === <%= RailsBase::Authentication::Constants::MFA_LENGTH %>;
|
57
|
+
if (<%= function_name %>()){
|
58
|
+
var mfa_string = $('#<%= mfa_id %>').val();
|
59
|
+
var curr_modal = '<%= modal_id %>';
|
60
|
+
var show_modal = '<%= next_modal %>';
|
61
|
+
var toggle_method = <%= modal_id %>_toggle
|
62
|
+
admin_risky_mfa_confirm(mfa_string, curr_modal, '<%= modal_mapping %>', <%= user.id %>, toggle_method, '<%= modify_id %>')
|
63
|
+
}
|
64
|
+
});
|
65
|
+
|
66
|
+
function invalidate_data(data) {
|
67
|
+
dataArr = data.split('');
|
68
|
+
var dataIsNotANumber = dataArr.every(function (pos) {
|
69
|
+
return isNaN(pos)
|
70
|
+
});
|
71
|
+
console.log(dataIsNotANumber)
|
72
|
+
return dataIsNotANumber
|
73
|
+
}
|
74
|
+
</script>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<% input_id = "#{type}_#{user.id}_#{(10**10*rand).to_i}_input" %>
|
2
|
+
<% span_id = "#{input_id}_span" %>
|
3
|
+
<% div_id = "#{input_id}_div" %>
|
4
|
+
<% toggle_function = "#{input_id}_function" %>
|
5
|
+
<% same_user = current_user == user %>
|
6
|
+
|
7
|
+
<% if !disable_action %>
|
8
|
+
<%= select_tag input_id, options_for_select(options, selector), class: 'form-control' %>
|
9
|
+
<button class="btn btn_info btn-block" id='<%= span_id %>' type="button" disabled style="display: none">
|
10
|
+
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true">
|
11
|
+
</span>
|
12
|
+
Hang tight
|
13
|
+
</button>
|
14
|
+
|
15
|
+
|
16
|
+
<script type="text/javascript">
|
17
|
+
var <%= input_id %> = '<%= selector %>'
|
18
|
+
function <%=toggle_function%>(reveal){
|
19
|
+
if(reveal){
|
20
|
+
$('#<%= input_id %>').hide()
|
21
|
+
$('#<%= span_id %>').show()
|
22
|
+
} else {
|
23
|
+
$('#<%= input_id %>').show()
|
24
|
+
$('#<%= span_id %>').hide()
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
$('#<%= input_id %>').change(function() {
|
29
|
+
admin_pause_concurrency();
|
30
|
+
|
31
|
+
var original = $("#<%= input_id %>").val();
|
32
|
+
<%=toggle_function%>(true);
|
33
|
+
var data = { 'attribute':'<%= type %>', 'value': original, 'id': <%= user.id %> }
|
34
|
+
$.ajax({
|
35
|
+
type: "POST",
|
36
|
+
url: "<%= RailsBase.url_routes.admin_upate_attribute_path%>",
|
37
|
+
headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') },
|
38
|
+
dataType: 'json',
|
39
|
+
data: data,
|
40
|
+
success: function(data) {
|
41
|
+
<%= input_id %> = original
|
42
|
+
admin_resume_concurrency();
|
43
|
+
<%=toggle_function%>(false);
|
44
|
+
admin_ensure_disabled();
|
45
|
+
_rails_base_display_success(data.message)
|
46
|
+
},
|
47
|
+
error: function(xhr, status, error) {
|
48
|
+
$('#<%= input_id %>').prop('checked', original);
|
49
|
+
<%=toggle_function%>(false);
|
50
|
+
$("#<%= input_id %>").val(<%= input_id %>);
|
51
|
+
admin_resume_concurrency();
|
52
|
+
admin_ensure_disabled();
|
53
|
+
_rails_base_display_alert(xhr.responseJSON.message)
|
54
|
+
}
|
55
|
+
})
|
56
|
+
})
|
57
|
+
</script>
|
58
|
+
<% else %>
|
59
|
+
<div>
|
60
|
+
<span style="width: 88%; float: left;">
|
61
|
+
<%= select_tag input_id, options_for_select(options, selector), class: 'form-control', disabled: true %>
|
62
|
+
</span>
|
63
|
+
<span style="width: 8%; float: right;">
|
64
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-question-circle" viewBox="0 0 16 16" data-toggle='tooltip' title='<%= disable_msg %> '>
|
65
|
+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
66
|
+
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
|
67
|
+
</svg>
|
68
|
+
</span>
|
69
|
+
</div>
|
70
|
+
<% end %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% input_id = "#{type}_#{user.id}_#{(10**10*rand).to_i}_input" %>
|
2
|
+
<% span_id = "#{input_id}_span" %>
|
3
|
+
<% div_span = "#{input_id}_div" %>
|
4
|
+
<% toggle_function = "#{input_id}_function" %>
|
5
|
+
|
6
|
+
<% if disable_action %>
|
7
|
+
<span style="width: 88%; float: left;">
|
8
|
+
<div id='<%= div_span %>' class='text-center'>
|
9
|
+
<input id='<%= input_id %>' class='admin-concurrent-block stay-disabled' type="checkbox" <%= 'checked' if checked %> data-toggle="toggle" data-on='<%= data_on %>' data-off='<%= data_off %>' data-onstyle='success' data-offstyle='warning' disabled>
|
10
|
+
</div>
|
11
|
+
</span>
|
12
|
+
<span style="width: 8%; float: right;">
|
13
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-question-circle" viewBox="0 0 16 16" data-toggle='tooltip' title='<%= disable_msg %> '>
|
14
|
+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
15
|
+
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
|
16
|
+
</svg>
|
17
|
+
</span>
|
18
|
+
<% else %>
|
19
|
+
<div id='<%= div_span %>' class='text-center'>
|
20
|
+
<input id='<%= input_id %>' class='admin-concurrent-block' type="checkbox" <%= 'checked' if checked %> data-toggle="toggle" data-on='<%= data_on %>' data-off='<%= data_off %>' data-onstyle='success' data-offstyle='warning'>
|
21
|
+
</div>
|
22
|
+
<button class="btn btn_info btn-block" id='<%= span_id %>' type="button" disabled style="display: none">
|
23
|
+
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true">
|
24
|
+
</span>
|
25
|
+
Hang tight
|
26
|
+
</button>
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
<script type="text/javascript">
|
31
|
+
$(document).ready(function(){
|
32
|
+
$('#<%= input_id %>').bootstrapToggle();
|
33
|
+
});
|
34
|
+
|
35
|
+
function <%=toggle_function%>(reveal){
|
36
|
+
if(reveal){
|
37
|
+
$('#<%= div_span %>').hide()
|
38
|
+
$('#<%= span_id %>').show()
|
39
|
+
} else {
|
40
|
+
$('#<%= div_span %>').show()
|
41
|
+
$('#<%= span_id %>').hide()
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
$('#<%= input_id %>').change(function() {
|
46
|
+
admin_pause_concurrency();
|
47
|
+
var original = $("#<%= input_id %>").is(':checked');
|
48
|
+
<%=toggle_function%>(true);
|
49
|
+
var data = { 'attribute':'<%= type %>', 'value': original, 'id': <%= user.id %> }
|
50
|
+
$.ajax({
|
51
|
+
type: "POST",
|
52
|
+
url: "<%= RailsBase.url_routes.admin_upate_attribute_path%>",
|
53
|
+
headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') },
|
54
|
+
dataType: 'json',
|
55
|
+
data: data,
|
56
|
+
success: function(data) {
|
57
|
+
admin_resume_concurrency();
|
58
|
+
<%=toggle_function%>(false);
|
59
|
+
admin_ensure_disabled();
|
60
|
+
_rails_base_display_success(data.message)
|
61
|
+
},
|
62
|
+
error: function(xhr, status, error) {
|
63
|
+
$('#<%= input_id %>').prop('checked', original);
|
64
|
+
<%=toggle_function%>(false);
|
65
|
+
admin_ensure_disabled();
|
66
|
+
admin_resume_concurrency();
|
67
|
+
_rails_base_display_alert(xhr.responseJSON.message)
|
68
|
+
}
|
69
|
+
})
|
70
|
+
})
|
71
|
+
</script>
|
72
|
+
<% end %>
|