blogelator 0.1.5 → 0.1.6
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 +4 -4
- data/app/controllers/concerns/blogelator/admin/auth.rb +37 -5
- data/lib/blogelator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df71289e4cc6e46f08ae106d85e09c816c42c6b
|
4
|
+
data.tar.gz: 4b681bfd0e777ba2ed89021179cfd20cb636d5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b59799baac3caf6722179a6ef3490954c14ff9c2af1e4ef91ff54644b8c75b326b825d7d66bae748fbc48bc6ad4c3cae1265164e0b8528d3007ba3ec7c24f25
|
7
|
+
data.tar.gz: 945d64199355dbae5c76198985caf4ded75909d452f81e4df1fd9a278de577f2bc7315990534b17b50021eb595170bf653eb616c533fe1066cbcad32b1caefd4
|
@@ -2,22 +2,54 @@ module Blogelator
|
|
2
2
|
module Admin
|
3
3
|
module Auth
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
6
|
included do
|
7
7
|
check_authorization
|
8
8
|
rescue_from CanCan::AccessDenied do |exception|
|
9
|
-
|
9
|
+
unauthorized(exception)
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def blogelator_current_user
|
14
14
|
respond_to?(:current_user) ? current_user : nil
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def current_ability
|
18
18
|
@current_ability ||= Blogelator::Ability.new(blogelator_current_user)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
def devise_resource_name
|
22
|
+
Blogelator.user_class.underscore.gsub('/', '_')
|
23
|
+
end
|
24
|
+
|
25
|
+
def login_redirect_path
|
26
|
+
# Try to use Devise's new session path or use the app's root path
|
27
|
+
devise_new_session_path = "new_#{devise_resource_name}_session_path"
|
28
|
+
if main_app.respond_to?(devise_new_session_path)
|
29
|
+
main_app.send(devise_new_session_path)
|
30
|
+
else
|
31
|
+
main_app.root_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def redirect_back_or_default(default)
|
36
|
+
redirect_to(session["#{devise_resource_name}_return_to"] || default)
|
37
|
+
session["#{devise_resource_name}_return_to"] = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def store_location
|
41
|
+
session["#{devise_resource_name}_return_to"] = request.fullpath.gsub('//', '/')
|
42
|
+
end
|
43
|
+
|
44
|
+
def unauthorized(exception)
|
45
|
+
if blogelator_current_user
|
46
|
+
redirect_to main_app.root_url, alert: exception.message
|
47
|
+
else
|
48
|
+
store_location
|
49
|
+
redirect_to login_redirect_path, alert: exception.message
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
21
53
|
end
|
22
54
|
end
|
23
55
|
end
|
data/lib/blogelator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blogelator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Pattison
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|