shopapp 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/shoplift_client.rb +14 -3
- data/shopapp.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11d8a7b899e944cfb00f6f4185f20d0813d443fd
|
4
|
+
data.tar.gz: 952204164e72577170ad84ffe6a1a3f69b911caa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b023e030673c89a256c11f73ff43a2b9b3405f2f72e6693b0808faf433e0f2b0cab4dc97e5942e8ed4f01ef78118985aa74ab654aa631445ccf427eac2eb65
|
7
|
+
data.tar.gz: 5b800820ded0a09c9f054067352a70dd7d89a80ff18a26f29882bafb6c2e893744f55f06189878c265a1f97b4b5b2d33b7d533b97d84b48f4da1dc673744f251
|
@@ -83,7 +83,12 @@ module ShopliftClient
|
|
83
83
|
redirect_unauthorized unless authenticate_user
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
86
|
+
def authenticate_user_or_api!
|
87
|
+
redirect_unauthorized unless authenticate_company!(true)
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def authenticate_company!(soft = false)
|
87
92
|
return if authenticate_user
|
88
93
|
|
89
94
|
@api_key = if params['key'].present?
|
@@ -94,7 +99,10 @@ module ShopliftClient
|
|
94
99
|
Rails.configuration.settings['authlift_default_app_key']
|
95
100
|
end
|
96
101
|
|
97
|
-
|
102
|
+
if @api_key.blank?
|
103
|
+
return false if soft
|
104
|
+
fail ActionController::RoutingError, 'Authentication token missing'
|
105
|
+
end
|
98
106
|
|
99
107
|
response = srv.post 'auth/api_key',
|
100
108
|
body: {
|
@@ -102,7 +110,10 @@ module ShopliftClient
|
|
102
110
|
requested_action: "#{self.controller_name}##{self.action_name}"
|
103
111
|
}
|
104
112
|
|
105
|
-
|
113
|
+
if response.blank?
|
114
|
+
return false if soft
|
115
|
+
fail ActionController::RoutingError, 'Request not authorized'
|
116
|
+
end
|
106
117
|
|
107
118
|
@authentication = JSON.parse response.body
|
108
119
|
find_company_by_code authentication['company']
|
data/shopapp.gemspec
CHANGED