rails_base 0.53.0 → 0.53.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rails_base/application.js +0 -1
- data/app/helpers/rails_base/appearance_helper.rb +2 -2
- data/app/helpers/rails_base/application_helper.rb +1 -1
- data/app/mailers/rails_base/email_verification_mailer.rb +3 -3
- data/app/mailers/rails_base/event_mailer.rb +2 -2
- data/app/models/rails_base/application_record.rb +1 -1
- data/app/models/short_lived_data.rb +2 -2
- data/app/models/user.rb +2 -2
- data/app/services/rails_base/admin_update_attribute.rb +1 -1
- data/app/views/layouts/rails_base/application.html.erb +1 -0
- data/app/views/rails_base/devise/registrations/new.html.erb +1 -1
- data/app/views/rails_base/email_verification_mailer/email_verification.html.erb +1 -1
- data/app/views/rails_base/email_verification_mailer/event.html.erb +1 -1
- data/app/views/rails_base/mfa_auth/mfa_code.html.erb +1 -0
- data/lib/rails_base/config.rb +3 -0
- data/lib/rails_base/configuration/admin.rb +0 -2
- data/lib/rails_base/configuration/app.rb +5 -5
- data/lib/rails_base/engine.rb +13 -12
- data/lib/rails_base/version.rb +1 -1
- data/lib/rails_base.rb +22 -1
- metadata +1 -2
- data/app/assets/javascripts/rails_base/cable.js +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d20109ef6d422bfe9f2d9ea381e0bae71bfd9cb9a3585554f97fb378baf00d50
|
4
|
+
data.tar.gz: '08666f477b07d62d5fffd6505785b12b643bc9164ccd1c038585f7d895fa78c7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67025f0a012ed6c7024671a048f74026f30b9870115f13f5c2ff047f1a5fed7e5b31e61c2074a8f193d5cdd8392465deaa816c6a651d9cfb6f2788de4bcfeb0
|
7
|
+
data.tar.gz: 3b44a97ffc9ebd160941fe29b517d1ab114b61250562a6a51d4cf72cb29702233b31b39c6aa550664527b1e78a787600549dba4c06e96c9b9c2feb2b838b30e3
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RailsBase::AppearanceHelper
|
2
|
-
APPEARANCE_MODE_COOKIE = "_#{
|
3
|
-
APPEARANCE_MODE_ACTUAL_COOKIE = "_#{
|
2
|
+
APPEARANCE_MODE_COOKIE = "_#{RailsBase.app_name}_appearance_mode".gsub(' ', '-').downcase
|
3
|
+
APPEARANCE_MODE_ACTUAL_COOKIE = "_#{RailsBase.app_name}_appearance_actual_mode".gsub(' ', '-').downcase
|
4
4
|
APPEARANCE_TEXT_CLASS = RailsBase::Configuration::Display::Text::APPEARANCE_TEXT_CLASS
|
5
5
|
|
6
6
|
VIEWPORT_EXTRA_SMALL = 'xs'.freeze
|
@@ -4,19 +4,19 @@ class RailsBase::EmailVerificationMailer < RailsBase::ApplicationMailer
|
|
4
4
|
def email_verification(user:, url:)
|
5
5
|
@user = user
|
6
6
|
@sso_url_for_user = url
|
7
|
-
mail(to: @user.email, subject: "Welcome to #{
|
7
|
+
mail(to: @user.email, subject: "Welcome to #{RailsBase.app_name}")
|
8
8
|
end
|
9
9
|
|
10
10
|
def forgot_password(user:, url:)
|
11
11
|
@user = user
|
12
12
|
@sso_url_for_user = url
|
13
|
-
mail(to: @user.email, subject: "#{
|
13
|
+
mail(to: @user.email, subject: "#{RailsBase.app_name}: Forgot Password")
|
14
14
|
end
|
15
15
|
|
16
16
|
def event(user:, event:, msg: nil)
|
17
17
|
@user = user
|
18
18
|
@event = event
|
19
19
|
@msg = msg
|
20
|
-
mail(to: @user.email, subject: "#{
|
20
|
+
mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}")
|
21
21
|
end
|
22
22
|
end
|
@@ -4,13 +4,13 @@ class RailsBase::EventMailer < RailsBase::ApplicationMailer
|
|
4
4
|
def send_sso(user:, message:)
|
5
5
|
@user = user
|
6
6
|
@message = message
|
7
|
-
mail(to: user.email, subject: "#{
|
7
|
+
mail(to: user.email, subject: "#{RailsBase.app_name}: SSO login", template_name: 'event')
|
8
8
|
# event(user: user, event: 'SSO login', message: message)
|
9
9
|
end
|
10
10
|
|
11
11
|
def event(user:, event:, message:)
|
12
12
|
@user = user
|
13
13
|
@message = message
|
14
|
-
mail(to: @user.email, subject: "#{
|
14
|
+
mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}", template_name: 'event')
|
15
15
|
end
|
16
16
|
end
|
@@ -6,7 +6,7 @@ module RailsBase
|
|
6
6
|
columns.each do |column|
|
7
7
|
next unless [:datetime].include?(column.type)
|
8
8
|
|
9
|
-
# This is actually pretty cool. If you set the
|
9
|
+
# This is actually pretty cool. If you set the thread corectly, you can
|
10
10
|
define_method("#{column.name}") do
|
11
11
|
thread_tz = Thread.current[RailsBase::ApplicationController::TIMEZONE_THREAD_NAME]
|
12
12
|
return super() if thread_tz.nil?
|
@@ -97,7 +97,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
|
|
97
97
|
# only update if count is valid and we can add things -- save db call
|
98
98
|
return false unless used_count_valid?
|
99
99
|
|
100
|
-
|
100
|
+
update(exclusive_use_count: exclusive_use_count + 1)
|
101
101
|
end
|
102
102
|
|
103
103
|
def invalid_reason
|
@@ -126,7 +126,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def user=(u)
|
129
|
-
|
129
|
+
update(user_id: u.id)
|
130
130
|
u.id
|
131
131
|
end
|
132
132
|
end
|
data/app/models/user.rb
CHANGED
@@ -50,7 +50,7 @@ class User < RailsBase::ApplicationRecord
|
|
50
50
|
end
|
51
51
|
|
52
52
|
define_method("admin_#{admin_method}!") do
|
53
|
-
|
53
|
+
update!(admin: admin_method)
|
54
54
|
end
|
55
55
|
|
56
56
|
#### metods on the class
|
@@ -109,7 +109,7 @@ class User < RailsBase::ApplicationRecord
|
|
109
109
|
return if last_known_timezone == tz_name
|
110
110
|
|
111
111
|
Rails.logger.info { "#{id}: Setting tz_name: #{tz_name}" }
|
112
|
-
|
112
|
+
update(last_known_timezone: tz_name, last_known_timezone_update: Time.now )
|
113
113
|
end
|
114
114
|
|
115
115
|
def timezone
|
@@ -14,7 +14,7 @@ module RailsBase
|
|
14
14
|
|
15
15
|
original_value = model_row.public_send(attribute)
|
16
16
|
begin
|
17
|
-
model_row.
|
17
|
+
model_row.update!(attribute => sanitized_value)
|
18
18
|
rescue ActiveRecord::RecordInvalid => e
|
19
19
|
context.fail!(message: "Failed to update [#{attribute}] with #{sanitized_value} on #{model}##{model_row.id}. #{e.message}")
|
20
20
|
rescue StandardError
|
@@ -126,6 +126,7 @@
|
|
126
126
|
</footer>
|
127
127
|
<% end %>
|
128
128
|
</div>
|
129
|
+
|
129
130
|
<% if RailsBase.appearance.back_to_top.enable? %>
|
130
131
|
<a id="rails-base-back-to-top" class="btn btn-light btn-lg back-to-top" role="button"><i class="fas fa-chevron-up"></i></a>
|
131
132
|
<script type="text/javascript">
|
@@ -69,7 +69,7 @@
|
|
69
69
|
<div class="col-md-10 offset-md-1 text-center">
|
70
70
|
<div class="row">
|
71
71
|
<div class="col-md-9">
|
72
|
-
<%= f.submit "Sign Up for #{
|
72
|
+
<%= f.submit "Sign Up for #{RailsBase.app_name}", class: "btn btn_success btn-block #{submit_klass}" %>
|
73
73
|
</div>
|
74
74
|
<div class="col-md-3">
|
75
75
|
<a class="btn btn_primary btn-block" href="<%=RailsBase.url_routes.new_user_session_path%>" role="button">Have an Account? Sign In</a>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
</p>
|
10
10
|
<% end %>
|
11
11
|
<p>
|
12
|
-
If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%=
|
12
|
+
If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%= RailsBase.app_name %> </a>
|
13
13
|
</p>
|
14
14
|
|
15
15
|
</br>
|
data/lib/rails_base/config.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
require 'rails_base/configuration/admin'
|
2
3
|
require 'rails_base/configuration/mfa'
|
3
4
|
require 'rails_base/configuration/authentication'
|
@@ -13,6 +14,8 @@ require 'rails_base/configuration/active_job'
|
|
13
14
|
|
14
15
|
module RailsBase
|
15
16
|
class Config
|
17
|
+
include Singleton
|
18
|
+
|
16
19
|
VARIABLES = {
|
17
20
|
admin: nil,
|
18
21
|
mfa: nil,
|
@@ -16,27 +16,27 @@ module RailsBase
|
|
16
16
|
},
|
17
17
|
web_name_logged_in: {
|
18
18
|
type: :string_proc,
|
19
|
-
default: ->(user) {
|
19
|
+
default: ->(user) { RailsBase.app_name },
|
20
20
|
description: 'Name of the application when authenticated user is present. Name in the tab of the browser. Allows for dynamic tab names'
|
21
21
|
},
|
22
22
|
web_name_logged_out: {
|
23
23
|
type: :string_proc,
|
24
|
-
default: ->(*) {
|
24
|
+
default: ->(*) { RailsBase.app_name },
|
25
25
|
description: 'Name of the application when no authenticated user. Name in the tab of the browser. Allows for dynamic tab names'
|
26
26
|
},
|
27
27
|
web_title_logged_in: {
|
28
28
|
type: :string_proc,
|
29
|
-
default: ->(user) {
|
29
|
+
default: ->(user) { RailsBase.app_name },
|
30
30
|
description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
|
31
31
|
},
|
32
32
|
web_title_logged_out: {
|
33
33
|
type: :string_proc,
|
34
|
-
default: ->(*) {
|
34
|
+
default: ->(*) { RailsBase.app_name },
|
35
35
|
description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
|
36
36
|
},
|
37
37
|
communication_name: {
|
38
38
|
type: :string_proc,
|
39
|
-
default: ->(*) {
|
39
|
+
default: ->(*) { RailsBase.app_name },
|
40
40
|
description: 'Name used when communicating with users.'
|
41
41
|
},
|
42
42
|
favicon_path: {
|
data/lib/rails_base/engine.rb
CHANGED
@@ -1,18 +1,26 @@
|
|
1
1
|
module RailsBase
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace RailsBase
|
4
|
+
ActiveSupport::Reloader.to_prepare do
|
5
|
+
if RailsBase.___execute_initializer___?
|
6
|
+
RailsBase.config.admin.convenience_methods
|
7
|
+
|
8
|
+
RailsBase::ApplicationRecord.descendants.each do |model|
|
9
|
+
model._magically_defined_time_objects
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
4
13
|
|
5
14
|
initializer 'instantiate RailsBase configs' do |_app|
|
6
|
-
RailsBase.config if ___execute_initializer___?
|
15
|
+
RailsBase.config if RailsBase.___execute_initializer___?
|
7
16
|
end
|
8
17
|
|
9
18
|
initializer 'remove write access to RailsBase config', after: 'after_initialize' do |app|
|
10
|
-
RailsBase::Configuration::Base._unset_allow_write! if ___execute_initializer___?
|
19
|
+
RailsBase::Configuration::Base._unset_allow_write! if RailsBase.___execute_initializer___?
|
11
20
|
end
|
12
21
|
|
13
22
|
initializer 'define magic convenionce methods for converting team', after: 'active_record.initialize_database' do |app|
|
14
|
-
if ___execute_initializer___?
|
15
|
-
raise
|
23
|
+
if RailsBase.___execute_initializer___?
|
16
24
|
# need to eager load Models
|
17
25
|
Rails.application.eager_load!
|
18
26
|
|
@@ -39,13 +47,6 @@ module RailsBase
|
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
|
-
|
43
|
-
# Only execute when not doing DB actions
|
44
|
-
boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
|
45
|
-
boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
|
46
|
-
boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
|
47
|
-
boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
|
48
|
-
boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
|
49
|
-
end
|
50
|
+
|
50
51
|
end
|
51
52
|
end
|
data/lib/rails_base/version.rb
CHANGED
data/lib/rails_base.rb
CHANGED
@@ -17,10 +17,31 @@ require 'rails_base/admin/action_cache'
|
|
17
17
|
require 'rails_base/config'
|
18
18
|
|
19
19
|
module RailsBase
|
20
|
+
|
21
|
+
# Rails 6 does not play nice with this function -- Find a different work around
|
22
|
+
def self.___execute_initializer___?
|
23
|
+
# Only execute when not doing DB actions
|
24
|
+
boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
|
25
|
+
boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
|
26
|
+
boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
|
27
|
+
boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
|
28
|
+
boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
|
29
|
+
|
30
|
+
boolean
|
31
|
+
end
|
32
|
+
|
20
33
|
def self.url_routes
|
21
34
|
Rails.application.routes.url_helpers
|
22
35
|
end
|
23
36
|
|
37
|
+
def self.app_name
|
38
|
+
if ::Rails::VERSION::MAJOR >= 6
|
39
|
+
::Rails.application.class.module_parent_name
|
40
|
+
else
|
41
|
+
::Rails.application.class.parent_name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
24
45
|
def self.route_exist?(path)
|
25
46
|
Rails.application.routes.recognize_path(path)
|
26
47
|
true
|
@@ -35,7 +56,7 @@ module RailsBase
|
|
35
56
|
end
|
36
57
|
|
37
58
|
def self.config
|
38
|
-
@config ||= RailsBase::Config.
|
59
|
+
@config ||= RailsBase::Config.instance
|
39
60
|
end
|
40
61
|
|
41
62
|
def self.appearance
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.53.
|
4
|
+
version: 0.53.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Taylor
|
@@ -409,7 +409,6 @@ files:
|
|
409
409
|
- app/assets/images/rails_base/favicon.ico
|
410
410
|
- app/assets/javascripts/rails_base/admin.js
|
411
411
|
- app/assets/javascripts/rails_base/application.js
|
412
|
-
- app/assets/javascripts/rails_base/cable.js
|
413
412
|
- app/assets/javascripts/rails_base/mfa_auth.coffee
|
414
413
|
- app/assets/javascripts/rails_base/secondary_authentication.coffee
|
415
414
|
- app/assets/javascripts/rails_base/sessions.js
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
-
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
-
//
|
4
|
-
//= require action_cable
|
5
|
-
//= require_self
|
6
|
-
//= require_tree ./channels
|
7
|
-
|
8
|
-
(function() {
|
9
|
-
this.App || (this.App = {});
|
10
|
-
|
11
|
-
App.cable = ActionCable.createConsumer();
|
12
|
-
|
13
|
-
}).call(this);
|