rails-image-post-solution 0.1.10 → 0.1.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cff46842aaf17f3755a392ae1b340330bb15b54c94616db8ed96c646efcc468
4
- data.tar.gz: c55be48295ec1c5366440b924b1101428f851d1fa913018eaed1bce968a434d6
3
+ metadata.gz: b486c6d4726a0d3774bf530d8fc27e2e5ee22a869535ae635b448991a896c46a
4
+ data.tar.gz: 9a6b640e3f4eb3ca43d9fd202284b0d095d1bd7c1d3be4d57b319f69489a173c
5
5
  SHA512:
6
- metadata.gz: 6b8f5fa256f33c94892be69b3c5aeed7b14cfd1be7a1451f79f8c574b5b53f0819acdf1a42b719be9dd24b591228c82eaaa016ad82e0d8e1def6ad94b9c37a97
7
- data.tar.gz: c6843b246611dcb5db6445dad0e8d33b0acaad626140dd4b8445dda7db3fda1989b44f0c6305c987c707d9c95344195783a6353573ba67b3903f89c20bbeb805
6
+ metadata.gz: 318733add4a1dfc760608aefc72f5ff7e54888a832dcaa9bf15c9d4a8437d426ccde18ef4c9ffa5e2d8158d1131e849a89b927794ed16e758b70ba9401d1ad6f
7
+ data.tar.gz: 872cec66f1cf53510f13e6de9ac3075997a875a3c1ce1669daa24c2f04b587ec548e9170f11db2c173ae4a98ff74d53997355092fb0f8dc4ba04d23c639003f5
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RailsImagePostSolution
4
4
  module Admin
5
- class FrozenPostsController < ApplicationController
5
+ class FrozenPostsController < RailsImagePostSolution::ApplicationController
6
6
  before_action :require_login
7
7
  before_action :require_admin
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RailsImagePostSolution
4
4
  module Admin
5
- class ImageReportsController < ApplicationController
5
+ class ImageReportsController < RailsImagePostSolution::ApplicationController
6
6
  before_action :require_login
7
7
  before_action :require_admin
8
8
  before_action :set_report, only: %i[show confirm dismiss]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RailsImagePostSolution
4
4
  module Admin
5
- class UsersController < ApplicationController
5
+ class UsersController < RailsImagePostSolution::ApplicationController
6
6
  before_action :require_login
7
7
  before_action :require_admin
8
8
  before_action :set_user, only: %i[show suspend unsuspend ban unban]
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsImagePostSolution
4
+ class ApplicationController < ::ApplicationController
5
+ # Engine's base controller inherits from host application's ApplicationController
6
+ # This allows the engine to use the host app's authentication methods
7
+
8
+ # Override require_login to use main_app routes
9
+ def require_login
10
+ unless logged_in?
11
+ redirect_to main_app.login_path, alert: I18n.t("errors.messages.login_required")
12
+ end
13
+ end
14
+
15
+ # Add require_admin method for admin controllers
16
+ def require_admin
17
+ unless logged_in?
18
+ redirect_to main_app.login_path, alert: I18n.t("errors.messages.login_required")
19
+ return
20
+ end
21
+
22
+ unless current_user.admin?
23
+ redirect_to main_app.root_path, alert: I18n.t("errors.messages.admin_required")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- class ImageReportsController < ApplicationController
4
+ class ImageReportsController < RailsImagePostSolution::ApplicationController
5
5
  before_action :require_login
6
6
  before_action :set_attachment, only: :create
7
7
 
@@ -9,9 +9,27 @@ module RailsImagePostSolution
9
9
  # Explicitly set engine root
10
10
  config.root = File.expand_path('../..', __dir__)
11
11
 
12
- # Explicitly autoload the Admin module before controllers
13
- config.before_initialize do
14
- require_dependency Engine.root.join('app/controllers/rails_image_post_solution/admin.rb')
12
+ # Eager load engine classes to ensure they're available
13
+ config.eager_load_paths += %W[
14
+ #{root}/app/controllers
15
+ ]
16
+
17
+ # Load admin module and controllers when app prepares
18
+ config.to_prepare do
19
+ # Ensure Admin module is loaded
20
+ unless defined?(RailsImagePostSolution::Admin)
21
+ require Engine.root.join('app/controllers/rails_image_post_solution/admin.rb')
22
+ end
23
+
24
+ # Ensure ApplicationController is loaded
25
+ unless defined?(RailsImagePostSolution::ApplicationController)
26
+ require Engine.root.join('app/controllers/rails_image_post_solution/application_controller.rb')
27
+ end
28
+
29
+ # Eager load all admin controllers
30
+ Dir[Engine.root.join('app/controllers/rails_image_post_solution/admin/**/*_controller.rb')].each do |file|
31
+ require file
32
+ end
15
33
  end
16
34
 
17
35
  # Load routes when engine is initialized
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.14"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-image-post-solution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler
@@ -97,6 +97,7 @@ files:
97
97
  - app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb
98
98
  - app/controllers/rails_image_post_solution/admin/image_reports_controller.rb
99
99
  - app/controllers/rails_image_post_solution/admin/users_controller.rb
100
+ - app/controllers/rails_image_post_solution/application_controller.rb
100
101
  - app/controllers/rails_image_post_solution/image_reports_controller.rb
101
102
  - app/jobs/rails_image_post_solution/image_moderation_job.rb
102
103
  - app/models/rails_image_post_solution/image_report.rb