milia 1.2.1 → 1.3.1.beta1

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 (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/confirmations_controller.rb +7 -7
  3. data/app/controllers/registrations_controller.rb +13 -19
  4. data/app/views/devise/registrations/new.html.haml +53 -0
  5. data/lib/generators/milia/install_generator.rb +44 -41
  6. data/lib/generators/milia/templates/devise_permitted_parameters.rb +18 -0
  7. data/lib/generators/milia/templates/initializer.rb +3 -9
  8. data/lib/milia.rb +3 -22
  9. data/lib/milia/base.rb +88 -109
  10. data/lib/milia/control.rb +25 -25
  11. data/lib/milia/invite_member.rb +6 -6
  12. data/lib/milia/version.rb +1 -1
  13. metadata +16 -184
  14. data/.document +0 -5
  15. data/.gitignore +0 -94
  16. data/.ruby-gemset +0 -1
  17. data/.ruby-version +0 -1
  18. data/.slugignore +0 -2
  19. data/.travis.yml +0 -4
  20. data/Gemfile +0 -4
  21. data/LICENSE.txt +0 -20
  22. data/README.md +0 -1207
  23. data/Rakefile +0 -1
  24. data/doc/gemfile_addition.txt +0 -28
  25. data/doc/manual_sample.sh +0 -816
  26. data/doc/ref_notes.txt +0 -155
  27. data/doc/sample.sh +0 -276
  28. data/markdown.rb +0 -38
  29. data/milia.gemspec +0 -29
  30. data/test/.ruby-gemset +0 -1
  31. data/test/.ruby-version +0 -1
  32. data/test/Gemfile +0 -81
  33. data/test/Gemfile.lock +0 -223
  34. data/test/README.md +0 -83
  35. data/test/Rakefile +0 -6
  36. data/test/app/assets/javascripts/application.js +0 -16
  37. data/test/app/assets/stylesheets/application.css +0 -13
  38. data/test/app/controllers/application_controller.rb +0 -13
  39. data/test/app/controllers/home_controller.rb +0 -10
  40. data/test/app/helpers/application_helper.rb +0 -2
  41. data/test/app/models/member.rb +0 -34
  42. data/test/app/models/post.rb +0 -14
  43. data/test/app/models/team.rb +0 -9
  44. data/test/app/models/team_asset.rb +0 -6
  45. data/test/app/models/tenant.rb +0 -54
  46. data/test/app/models/user.rb +0 -14
  47. data/test/app/models/zine.rb +0 -8
  48. data/test/app/views/home/index.html.erb +0 -2
  49. data/test/app/views/home/show.html.erb +0 -2
  50. data/test/app/views/layouts/application.html.erb +0 -14
  51. data/test/bin/bundle +0 -3
  52. data/test/bin/rails +0 -4
  53. data/test/bin/rake +0 -4
  54. data/test/config/application.rb +0 -36
  55. data/test/config/boot.rb +0 -4
  56. data/test/config/database.yml +0 -25
  57. data/test/config/environment.rb +0 -5
  58. data/test/config/environments/development.rb +0 -48
  59. data/test/config/environments/production.rb +0 -95
  60. data/test/config/environments/test.rb +0 -42
  61. data/test/config/initializers/backtrace_silencers.rb +0 -7
  62. data/test/config/initializers/devise.rb +0 -254
  63. data/test/config/initializers/filter_parameter_logging.rb +0 -4
  64. data/test/config/initializers/inflections.rb +0 -16
  65. data/test/config/initializers/milia.rb +0 -51
  66. data/test/config/initializers/mime_types.rb +0 -5
  67. data/test/config/initializers/secret_token.rb +0 -12
  68. data/test/config/initializers/session_store.rb +0 -3
  69. data/test/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/config/locales/en.yml +0 -23
  71. data/test/config/routes.rb +0 -77
  72. data/test/db/migrate/20111012050200_add_sessions_table.rb +0 -12
  73. data/test/db/migrate/20111012050340_devise_create_users.rb +0 -48
  74. data/test/db/migrate/20111012050532_create_tenants.rb +0 -11
  75. data/test/db/migrate/20111012050600_create_tenants_users_join_table.rb +0 -8
  76. data/test/db/migrate/20111012050650_create_members.rb +0 -12
  77. data/test/db/migrate/20111012231923_create_posts.rb +0 -12
  78. data/test/db/migrate/20111013050657_create_zines.rb +0 -10
  79. data/test/db/migrate/20111013050753_create_teams.rb +0 -10
  80. data/test/db/migrate/20111013050837_create_team_assets.rb +0 -11
  81. data/test/db/schema.rb +0 -126
  82. data/test/db/seeds.rb +0 -7
  83. data/test/test/controllers/home_controller_test.rb +0 -132
  84. data/test/test/ctlr_test_helper.rb +0 -11
  85. data/test/test/fixtures/members.yml +0 -35
  86. data/test/test/fixtures/posts.yml +0 -96
  87. data/test/test/fixtures/team_assets.yml +0 -30
  88. data/test/test/fixtures/teams.yml +0 -17
  89. data/test/test/fixtures/tenants.yml +0 -12
  90. data/test/test/fixtures/tenants_users.yml +0 -15
  91. data/test/test/fixtures/users.yml +0 -33
  92. data/test/test/fixtures/zines.yml +0 -25
  93. data/test/test/models/member_test.rb +0 -75
  94. data/test/test/models/post_test.rb +0 -66
  95. data/test/test/models/team_test.rb +0 -49
  96. data/test/test/models/tenant_test.rb +0 -228
  97. data/test/test/models/user_test.rb +0 -182
  98. data/test/test/models/zine_test.rb +0 -40
  99. data/test/test/test_helper.rb +0 -31
@@ -0,0 +1,18 @@
1
+ module DevisePermittedParameters
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_filter :configure_permitted_parameters
6
+ end
7
+
8
+ protected
9
+
10
+ def configure_permitted_parameters
11
+ devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
12
+ devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation, :current_password])
13
+
14
+ end
15
+
16
+ end
17
+
18
+ DeviseController.send :include, DevisePermittedParameters
@@ -5,9 +5,9 @@ Milia.setup do |config|
5
5
 
6
6
  # true if you wish to use a coupon-based option in your sign-up form
7
7
  # false to otherwise not expect a coupon attribute in the parameters
8
- config.use_coupon = true
8
+ config.use_coupon = false
9
9
 
10
- # true if you use recaptcha on your sign-up form;
10
+ # true if you use recaptcha on your sign-up form;
11
11
  # be sure to include the gem 'recaptcha' in your Gemfile
12
12
  # false if you do not
13
13
  config.use_recaptcha = <%= !@skip_recaptcha %>
@@ -20,7 +20,7 @@ Milia.setup do |config|
20
20
  # be sure to include the gem 'airbrake' in your Gemfile
21
21
  # false if you do not
22
22
  # In certain situations, milia will notify airbrake of a situation which
23
- # is not necessarily an exception: such as if someone attempts to
23
+ # is not necessarily an exception: such as if someone attempts to
24
24
  # sign up but you're limited new sign ups (such as when in beta mode)
25
25
  # then you'll get notified via airbrake of the email of the person
26
26
  # attempting the signup (in case you wish to contact them)
@@ -30,12 +30,6 @@ Milia.setup do |config|
30
30
  # ASSUMES User model
31
31
  config.use_invite_member = <%= !@skip_invite_member %>
32
32
 
33
- # whitelist user params list
34
- # allows an app to expand the permitted attribute list
35
- # specify each attribute as a symbol
36
- # example: [:name]
37
- # config.whitelist_user_params = []
38
-
39
33
  # whitelist tenant params list
40
34
  # allows an app to expand the permitted attribute list
41
35
  # specify each attribute as a symbol
@@ -29,30 +29,11 @@ module Milia
29
29
  mattr_accessor :use_invite_member
30
30
  @@use_invite_member = true
31
31
 
32
-
33
- # whitelist user params list
34
- # allows an app to expand the permitted attribute list
35
- # specify each attribute as a symbol
36
- # example: [:name]
37
- # config.whitelist_user_params = []
38
- @@whitelist_user_params = []
39
-
40
- def self.whitelist_user_params=(list)
41
- raise ArgumentError unless !list.nil? && list.kind_of?( Array )
42
- @@whitelist_user_params = list
43
- end
44
-
45
- def self.whitelist_user_params()
46
- return [:email, :password, :password_confirmation] +
47
- @@whitelist_user_params
48
- end
49
-
50
-
51
- # whitelist user params list
32
+ # whitelist tenant params list
52
33
  # allows an app to expand the permitted attribute list
53
34
  # specify each attribute as a symbol
54
35
  # example: [:name]
55
- # config.whitelist_user_params = []
36
+ # config.whitelist_tenant_params = []
56
37
  @@whitelist_tenant_params = []
57
38
 
58
39
  def self.whitelist_tenant_params=(list)
@@ -68,7 +49,7 @@ module Milia
68
49
  # allows an app to expand the permitted attribute list
69
50
  # specify each attribute as a symbol
70
51
  # example: [:name]
71
- # config.whitelist_user_params = []
52
+ # config.whitelist_coupon_params = []
72
53
  @@whitelist_coupon_params = []
73
54
 
74
55
  def self.whitelist_coupon_params=(list)
@@ -14,36 +14,29 @@ module Milia
14
14
  # Forces all references to be limited to current_tenant rows
15
15
  # ------------------------------------------------------------------------
16
16
  def acts_as_tenant()
17
- belongs_to :tenant
17
+ belongs_to :tenant
18
18
  validates_presence_of :tenant_id
19
19
 
20
- default_scope lambda { where( "#{table_name}.tenant_id = ?", Thread.current[:tenant_id] ) }
20
+ default_scope lambda { where("#{table_name}.tenant_id = ?", Thread.current[:tenant_id]) }
21
21
 
22
- # ..........................callback enforcers............................
23
- before_validation(:on => :create) do |obj| # force tenant_id to be correct for current_user
24
- obj.tenant_id = Thread.current[:tenant_id]
25
- true # ok to proceed
22
+ # ..........................callback enforcers............................
23
+ after_initialize do |obj|
24
+ # Whenever we initialize a new object it needs to have the correct tenant_id of the current_user.
25
+ # Ensures that destroy can be called on tenanted records which haven't been persisted yet.
26
+ obj.tenant_id ||= Thread.current[:tenant_id]
26
27
  end
27
28
 
28
- # ..........................callback enforcers............................
29
- before_save do |obj| # force tenant_id to be correct for current_user
29
+ # ..........................callback enforcers............................
30
+ before_save do |obj| # force tenant_id to be correct for current_user
30
31
  # raise exception if updates attempted on wrong data
31
32
  raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id == Thread.current[:tenant_id]
32
- true # ok to proceed
33
33
  end
34
34
 
35
- # ..........................callback enforcers............................
36
- # no longer needed because before_save invoked prior to before_update
37
- #
38
- # before_update do |obj| # force tenant_id to be correct for current_user
39
- # raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id == Thread.current[:tenant_id]
40
- # true # ok to proceed
41
- # end
42
-
43
- # ..........................callback enforcers............................
44
- before_destroy do |obj| # force tenant_id to be correct for current_user
45
- raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id == Thread.current[:tenant_id]
46
- true # ok to proceed
35
+ # ..........................callback enforcers............................
36
+ before_destroy do |obj| # force tenant_id to be correct for current_user
37
+ if (obj.tenant_id != Thread.current[:tenant_id])
38
+ raise ::Milia::Control::InvalidTenantAccess
39
+ end
47
40
  end
48
41
 
49
42
  end
@@ -53,32 +46,24 @@ module Milia
53
46
  # Forces all reference to the universal tenant (nil)
54
47
  # ------------------------------------------------------------------------
55
48
  def acts_as_universal()
56
- belongs_to :tenant
49
+ belongs_to :tenant
57
50
 
58
- default_scope { where( "#{table_name}.tenant_id IS NULL" ) }
51
+ default_scope { where("#{table_name}.tenant_id IS NULL") }
59
52
 
60
- # ..........................callback enforcers............................
61
- before_save do |obj| # force tenant_id to be universal
62
- raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id.nil?
63
- true # ok to proceed
53
+ # ..........................callback enforcers............................
54
+ before_save do |obj| # force tenant_id to be universal
55
+ if obj.tenant_id.present?
56
+ raise ::Milia::Control::InvalidTenantAccess
57
+ end
64
58
  end
65
59
 
66
- # ..........................callback enforcers............................
67
- # before_update do |obj| # force tenant_id to be universal
68
- # no longer needed because before_save invoked prior to before_update
69
- #
70
- # raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id.nil?
71
- # true # ok to proceed
72
- # end
73
-
74
- # ..........................callback enforcers............................
75
- before_destroy do |obj| # force tenant_id to be universal
60
+ # ..........................callback enforcers............................
61
+ before_destroy do |obj| # force tenant_id to be universal
76
62
  raise ::Milia::Control::InvalidTenantAccess unless obj.tenant_id.nil?
77
- true # ok to proceed
78
63
  end
79
64
 
80
65
  end
81
-
66
+
82
67
  # ------------------------------------------------------------------------
83
68
  # acts_as_universal_and_determines_tenant_reference
84
69
  # All the characteristics of acts_as_universal AND also does the magic
@@ -90,96 +75,96 @@ module Milia
90
75
 
91
76
  acts_as_universal()
92
77
 
93
- # validate that a tenant exists prior to a user creation
78
+ # validate that a tenant exists prior to a user creation
94
79
  before_create do |new_user|
95
80
  if Thread.current[:tenant_id].blank? ||
96
- !Thread.current[:tenant_id].kind_of?(Integer) ||
97
- Thread.current[:tenant_id].zero?
81
+ !Thread.current[:tenant_id].kind_of?(Integer) ||
82
+ Thread.current[:tenant_id].zero?
98
83
 
99
- raise ::Milia::Control::InvalidTenantAccess,"no existing valid current tenant"
84
+ raise ::Milia::Control::InvalidTenantAccess, "no existing valid current tenant"
100
85
 
101
86
  end
102
- end # before create callback do
103
-
104
- # before create, tie user with current tenant
105
- # return true if ok to proceed; false if break callback chain
87
+ end # before create callback do
88
+
89
+ # before create, tie user with current tenant
106
90
  after_create do |new_user|
107
- tenant = Tenant.find( Thread.current[:tenant_id] )
91
+ tenant = Tenant.find(Thread.current[:tenant_id])
108
92
  unless tenant.users.include?(new_user)
109
- tenant.users << new_user # add user to this tenant if not already there
93
+ tenant.users << new_user # add user to this tenant if not already there
110
94
  end
111
-
112
95
  end # before_create do
113
-
96
+
114
97
  before_destroy do |old_user|
115
- old_user.tenants.clear # remove all tenants for this user
116
- true
98
+ old_user.tenants.clear # remove all tenants for this user
117
99
  end # before_destroy do
118
-
119
- end # acts_as
100
+
101
+ end
120
102
 
121
103
  # ------------------------------------------------------------------------
122
104
  # ------------------------------------------------------------------------
123
- def acts_as_universal_and_determines_tenant()
124
- has_and_belongs_to_many :users
105
+ def acts_as_universal_and_determines_tenant()
106
+ has_and_belongs_to_many :users
125
107
 
126
- acts_as_universal()
127
-
128
- before_destroy do |old_tenant|
129
- old_tenant.users.clear # remove all users from this tenant
130
- true
131
- end # before_destroy do
132
- end
108
+ acts_as_universal()
109
+
110
+ before_destroy do |old_tenant|
111
+ old_tenant.users.clear # remove all users from this tenant
112
+ true
113
+ end # before_destroy do
114
+ end
133
115
 
134
116
  # ------------------------------------------------------------------------
135
117
  # current_tenant -- returns tenant obj for current tenant
136
- # return nil if no current tenant defined
118
+ # return nil if no current tenant defined
137
119
  # ------------------------------------------------------------------------
138
- def current_tenant()
139
- begin
140
- tenant = (
141
- Thread.current[:tenant_id].blank? ?
142
- nil :
143
- Tenant.find( Thread.current[:tenant_id] )
144
- )
120
+ def current_tenant()
121
+ begin
122
+ tenant = (
123
+ Thread.current[:tenant_id].blank? ?
124
+ nil :
125
+ Tenant.find(Thread.current[:tenant_id])
126
+ )
127
+
128
+ return tenant
145
129
 
146
- return tenant
130
+ rescue ActiveRecord::RecordNotFound
131
+ return nil
132
+ end
133
+ end
147
134
 
148
- rescue ActiveRecord::RecordNotFound
149
- return nil
150
- end
151
- end
152
-
153
135
  # ------------------------------------------------------------------------
154
136
  # current_tenant_id -- returns tenant_id for current tenant
155
137
  # ------------------------------------------------------------------------
156
- def current_tenant_id()
157
- return Thread.current[:tenant_id]
158
- end
159
-
138
+ def current_tenant_id()
139
+ return Thread.current[:tenant_id]
140
+ end
141
+
160
142
  # ------------------------------------------------------------------------
161
143
  # set_current_tenant -- model-level ability to set the current tenant
162
144
  # NOTE: *USE WITH CAUTION* normally this should *NEVER* be done from
163
145
  # the models ... it's only useful and safe WHEN performed at the start
164
146
  # of a background job (DelayedJob#perform)
165
147
  # ------------------------------------------------------------------------
166
- def set_current_tenant( tenant )
167
- # able to handle tenant obj or tenant_id
168
- case tenant
169
- when Tenant then tenant_id = tenant.id
170
- when Integer then tenant_id = tenant
171
- else
172
- raise ArgumentError, "invalid tenant object or id"
173
- end # case
174
-
175
- old_id = ( Thread.current[:tenant_id].nil? ? '%' : Thread.current[:tenant_id] )
176
- Thread.current[:tenant_id] = tenant_id
177
- logger.debug("MILIA >>>>> [Tenant#change_tenant] new: #{tenant_id}\told:#{old_id}") unless logger.nil?
148
+ def set_current_tenant(tenant)
149
+ # able to handle tenant obj or tenant_id
150
+ case tenant
151
+ when Tenant then
152
+ tenant_id = tenant.id
153
+ when Integer then
154
+ tenant_id = tenant
155
+ else
156
+ raise ArgumentError, "invalid tenant object or id"
157
+ end # case
158
+
159
+ old_id = (Thread.current[:tenant_id].nil? ? '%' : Thread.current[:tenant_id])
160
+ Thread.current[:tenant_id] = tenant_id
161
+ logger.debug("MILIA >>>>> [Tenant#change_tenant] new: #{tenant_id}\told:#{old_id}") unless logger.nil?
162
+
163
+ end
178
164
 
179
- end
180
165
  # ------------------------------------------------------------------------
181
166
  # ------------------------------------------------------------------------
182
-
167
+
183
168
  # ------------------------------------------------------------------------
184
169
  # where_restrict_tenant -- gens tenant restrictive where clause for each klass
185
170
  # NOTE: subordinate join tables will not get the default scope by Rails
@@ -188,22 +173,16 @@ module Milia
188
173
  # right. adding an additional .where( where_restrict_tenants(klass1, klass2,...))
189
174
  # for each of the subordinate models in the join seems like a nice safety issue.
190
175
  # ------------------------------------------------------------------------
191
- def where_restrict_tenant(*args)
192
- args.map{|klass| "#{klass.table_name}.tenant_id = #{Thread.current[:tenant_id]}"}.join(" AND ")
193
- end
194
-
195
- # ------------------------------------------------------------------------
196
- # ------------------------------------------------------------------------
197
-
198
- # ------------------------------------------------------------------------
199
- # ------------------------------------------------------------------------
176
+ def where_restrict_tenant(*args)
177
+ args.map { |klass| "#{klass.table_name}.tenant_id = #{Thread.current[:tenant_id]}" }.join(" AND ")
178
+ end
200
179
 
201
180
  # ------------------------------------------------------------------------
202
181
  # ------------------------------------------------------------------------
203
182
 
204
- end # module ClassMethods
183
+ end # module ClassMethods
205
184
  # #############################################################################
206
185
  # #############################################################################
207
-
208
- end # module Base
209
- end # module Milia
186
+
187
+ end # module Base
188
+ end # module Milia
@@ -5,7 +5,7 @@ module Milia
5
5
  class InvalidTenantAccess < SecurityError; end
6
6
  class MaxTenantExceeded < ArgumentError; end
7
7
  # #############################################################################
8
-
8
+
9
9
  def self.included(base)
10
10
  base.extend ClassMethods
11
11
  end
@@ -13,11 +13,11 @@ module Milia
13
13
  # #############################################################################
14
14
  # #############################################################################
15
15
  module ClassMethods
16
-
16
+
17
17
  end # module ClassMethods
18
18
  # #############################################################################
19
19
  # #############################################################################
20
-
20
+
21
21
  public
22
22
 
23
23
  # ------------------------------------------------------------------------------
@@ -32,7 +32,7 @@ module Milia
32
32
 
33
33
  # ------------------------------------------------------------------------------
34
34
  # ------------------------------------------------------------------------------
35
- def __milia_reset_tenant!( )
35
+ def __milia_reset_tenant!
36
36
  __milia_change_tenant!( nil )
37
37
  logger.debug("MILIA >>>>> [reset tenant] ") unless logger.nil?
38
38
  end
@@ -43,8 +43,8 @@ module Milia
43
43
  if ::Milia.trace_on
44
44
  tid = ( session[:tenant_id].nil? ? "%/#{Thread.current[:tenant_id]}" : session[:tenant_id].to_s )
45
45
  uid = ( current_user.nil? ? "%/#{session[:user_id]}" : "#{current_user.id}")
46
- logger.debug(
47
- "MILIA >>>>> [#{fm_msg}] stid: #{tid}\tuid: #{uid}\tus-in: #{user_signed_in?}"
46
+ logger.debug(
47
+ "MILIA >>>>> [#{fm_msg}] stid: #{tid}\tuid: #{uid}\tus-in: #{user_signed_in?}"
48
48
  ) unless logger.nil?
49
49
  end # trace check
50
50
  end
@@ -58,11 +58,11 @@ module Milia
58
58
  def set_current_tenant( tenant_id = nil )
59
59
 
60
60
  if user_signed_in?
61
-
61
+
62
62
  @_my_tenants ||= current_user.tenants # gets all possible tenants for user
63
-
63
+
64
64
  tenant_id ||= session[:tenant_id] # use session tenant_id ?
65
-
65
+
66
66
  if tenant_id.nil? # no arg; find automatically based on user
67
67
  tenant_id = @_my_tenants.first.id # just pick the first one
68
68
  else # validate the specified tenant_id before setup
@@ -73,12 +73,12 @@ module Milia
73
73
  tenant_id = nil # an impossible tenant_id
74
74
  end
75
75
 
76
- __milia_change_tenant!( tenant_id )
76
+ __milia_change_tenant!( tenant_id )
77
77
  trace_tenanting( "set_current_tenant" )
78
78
 
79
79
  true # before filter ok to proceed
80
80
  end
81
-
81
+
82
82
  # ------------------------------------------------------------------------------
83
83
  # initiate_tenant -- initiates first-time tenant; establishes thread
84
84
  # assumes not in a session yet (since here only upon new account sign-up)
@@ -87,9 +87,9 @@ module Milia
87
87
  # tenant -- tenant obj of the new tenant
88
88
  # ------------------------------------------------------------------------------
89
89
  def initiate_tenant( tenant )
90
- __milia_change_tenant!( tenant.id )
90
+ __milia_change_tenant!( tenant.id )
91
91
  end
92
-
92
+
93
93
  # ------------------------------------------------------------------------------
94
94
  # ------------------------------------------------------------------------------
95
95
 
@@ -98,8 +98,8 @@ module Milia
98
98
  # -- authenticates user
99
99
  # -- sets current tenant
100
100
  # ------------------------------------------------------------------------------
101
- def authenticate_tenant!()
102
- unless authenticate_user!(force: true)
101
+ def authenticate_tenant!
102
+ unless current_user.present? || authenticate_user!(force: true)
103
103
  email = ( params.nil? || params[:user].nil? ? "<email missing>" : params[:user][:email] )
104
104
  flash[:error] = "cannot sign in as #{email}; check email/password"
105
105
  logger.info("MILIA >>>>> [failed auth user] ") unless logger.nil?
@@ -123,33 +123,33 @@ module Milia
123
123
 
124
124
  # ------------------------------------------------------------------------------
125
125
  # ------------------------------------------------------------------------------
126
- def max_tenants()
126
+ def max_tenants
127
127
  logger.info(
128
- "MILIA >>>>> [max tenant signups] #{Time.now.to_s(:db)} - User: #{params[:user][:email]}, org: #{params[:tenant][:name]}"
128
+ "MILIA >>>>> [max tenant signups] #{Time.now.to_s(:db)} - User: '#{params[:user].try(:email)}', Tenant: '#{params[:tenant].try(:name)}'"
129
129
  ) unless logger.nil?
130
130
 
131
131
  flash[:error] = "Sorry: new accounts not permitted at this time"
132
-
132
+
133
133
  # if using Airbrake & airbrake gem
134
134
  if ::Milia.use_airbrake
135
135
  notify_airbrake( $! ) # have airbrake report this -- requires airbrake gem
136
136
  end
137
137
  redirect_back
138
138
  end
139
-
139
+
140
140
  # ------------------------------------------------------------------------------
141
141
  # invalid_tenant -- using wrong or bad data
142
142
  # ------------------------------------------------------------------------------
143
143
  def invalid_tenant
144
- flash[:error] = "wrong tenant access; sign out & try again"
144
+ flash[:error] = "Wrong tenant access"
145
145
  redirect_back
146
146
  end
147
-
147
+
148
148
  # ------------------------------------------------------------------------------
149
149
  # redirect_back -- bounce client back to referring page
150
150
  # ------------------------------------------------------------------------------
151
151
  def redirect_back
152
- redirect_to :back rescue redirect_to root_path
152
+ super(fallback_location: root_path)
153
153
  end
154
154
 
155
155
  # ------------------------------------------------------------------------------
@@ -166,15 +166,15 @@ module Milia
166
166
  return option_obj if option_obj.instance_of?(klass)
167
167
  option_obj ||= {} # if nil, makes it empty hash
168
168
  return klass.send( :new, option_obj )
169
- end
169
+ end
170
170
 
171
171
  # ------------------------------------------------------------------------------
172
172
  # prep_signup_view -- prepares for the signup view
173
173
  # args:
174
174
  # tenant: either existing tenant obj or params for tenant
175
175
  # user: either existing user obj or params for user
176
- # My signup form has fields for user's email,
177
- # organization's name (tenant model), coupon code,
176
+ # My signup form has fields for user's email,
177
+ # organization's name (tenant model), coupon code,
178
178
  # ------------------------------------------------------------------------------
179
179
  def prep_signup_view(tenant=nil, user=nil, coupon={coupon:''})
180
180
  @user = klass_option_obj( User, user )