rails-image-post-solution 0.1.20 → 0.1.22
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8100148b481f465bd51a674e2f58b8d523c0dc8839282b165964bb69cd8621b0
|
|
4
|
+
data.tar.gz: 7cb7bd81eca38077723bd9619d02426e8ff7abd00e2b7480dbf684483e9ea81e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6d48840b4c2f604623117478236ff64bf0b98193b9db15bd05f5793d84f4786bb0d202b7025060232fb40049b9cc5e1fd44b9273f3604054ecd59689f3e8470
|
|
7
|
+
data.tar.gz: 5eeacad90090ffbc5b141ade98ff9fa656e10c8313749ec005fcf52323940d38480744ce54a99571370baa2fc956228560f4451a9cd5b84d9a06a3e7e460f935
|
|
@@ -5,26 +5,43 @@ module RailsImagePostSolution
|
|
|
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
7
|
|
|
8
|
-
#
|
|
9
|
-
|
|
8
|
+
# Include main app's route helpers
|
|
9
|
+
include Rails.application.routes.url_helpers
|
|
10
|
+
helper Rails.application.routes.url_helpers
|
|
11
|
+
|
|
12
|
+
# Add engine view path before rendering
|
|
13
|
+
before_action :add_engine_view_path
|
|
10
14
|
|
|
11
15
|
# Override require_login to use main_app routes
|
|
12
16
|
def require_login
|
|
13
17
|
unless logged_in?
|
|
14
|
-
redirect_to
|
|
18
|
+
redirect_to login_path, alert: I18n.t("errors.messages.login_required")
|
|
15
19
|
end
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
# Add require_admin method for admin controllers
|
|
19
23
|
def require_admin
|
|
20
24
|
unless logged_in?
|
|
21
|
-
redirect_to
|
|
25
|
+
redirect_to login_path, alert: I18n.t("errors.messages.login_required")
|
|
22
26
|
return
|
|
23
27
|
end
|
|
24
28
|
|
|
25
29
|
unless current_user.admin?
|
|
26
|
-
redirect_to
|
|
30
|
+
redirect_to root_path, alert: I18n.t("errors.messages.admin_required")
|
|
27
31
|
end
|
|
28
32
|
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def add_engine_view_path
|
|
37
|
+
prepend_view_path Engine.root.join("app", "views")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Make main_app available as a helper for engine routes
|
|
41
|
+
helper_method :main_app
|
|
42
|
+
|
|
43
|
+
def main_app
|
|
44
|
+
Rails.application.routes.url_helpers
|
|
45
|
+
end
|
|
29
46
|
end
|
|
30
47
|
end
|