rails-image-post-solution 0.1.13 → 0.1.15

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: f2ec235984ebcb48ca00c9de257a7c8270476ebf7b277eec2a6d2b5597442114
4
- data.tar.gz: d6dad1b4c10d93752525f11c95fad77fe436aab80b8752e28d861a8c5658e753
3
+ metadata.gz: 8af526e158a676bd8774a92896fc6fcb90e07358a83f17634fdf9ec277f2f875
4
+ data.tar.gz: 1bb02b2de8078d9178240a6a2d67acef480b78212d94419cdaa97fbefb265ec9
5
5
  SHA512:
6
- metadata.gz: 04356a80b8bc3dd7340a2a657430b16f1d1c70b56a0025e3af525f3333e35968b83a9497b7e0ea35917481dfe20e339b2eb4b3a5e098838e7e2f64d29193c99f
7
- data.tar.gz: e93cd8685eefed70b6445911ae27ec266ac78567b502a5e96120cb94c63b95127d4bbf98f4ba04047e14e22ebe84cec64605dd9671df956c7d771cdb60daebf7
6
+ metadata.gz: fc07b765e0f7fd90cc783d9d8b5ce9505db8b574ea077d6b641ff31c4b1c45d07a2dbe7bb182b84bf2b649b9ebfec14d05a094496765a4c0438a9fbb0642a3dc
7
+ data.tar.gz: 96680a6f9957c9421b2f54e107019094822ad619211782fea7a3828b7a26405efba1bbf20744c06a34403fb7645bc477c1c9dc0c93e32d0415b7b2b79849fffd
@@ -4,5 +4,24 @@ module RailsImagePostSolution
4
4
  class ApplicationController < ::ApplicationController
5
5
  # Engine's base controller inherits from host application's ApplicationController
6
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
7
26
  end
8
27
  end
@@ -71,17 +71,5 @@ module RailsImagePostSolution
71
71
  end
72
72
  end
73
73
  end
74
-
75
- def require_login
76
- # Call authentication method implemented in host application
77
- return if respond_to?(:current_user) && current_user
78
-
79
- respond_to do |format|
80
- format.json do
81
- render json: { error: I18n.t("rails_image_post_solution.flash.login_required") }, status: :unauthorized
82
- end
83
- format.html { redirect_to main_app.root_path, alert: I18n.t("rails_image_post_solution.flash.login_required") }
84
- end
85
- end
86
74
  end
87
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- VERSION = "0.1.13"
4
+ VERSION = "0.1.15"
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.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler