clowk 0.5.0 → 0.5.1
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/lib/clowk/authenticable.rb +26 -13
- data/lib/clowk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5027a092ba122ab807f5c0340bc30399f7ab85f9ef41bc99c5610b68df6f47f7
|
|
4
|
+
data.tar.gz: 1f0dd44bf7696a1e3cffed45cb4c48edc92db3025007db39c6ea721f119619a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20a10b0715b1695694c51b915490ad852ba43004e9f1ec1b0fbc7af1d192737250234d4342ea1cac3db7ef6a94dc992b17795ee5ab2f0e0fcc6b23e7237a7c27
|
|
7
|
+
data.tar.gz: 124f14e7d6e53e7c904faa98befc85d18e7f1644f02d654a01c037555d589f4085069945435c7c81aaad36db4158b019b8f61faaeb359ac61839b09edf65d7a0
|
data/lib/clowk/authenticable.rb
CHANGED
|
@@ -116,11 +116,18 @@ module Clowk
|
|
|
116
116
|
|
|
117
117
|
private
|
|
118
118
|
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
119
|
+
# ActionController::API is the reliable signal, and it has to be checked
|
|
120
|
+
# directly. Probing `session` does not work: with no session middleware
|
|
121
|
+
# loaded, `request.session` still returns a Session object that responds to
|
|
122
|
+
# `[]` and reads as nil — writes vanish, but nothing raises. Inferring
|
|
123
|
+
# "there is a session, so this is a browser" from that answered every API
|
|
124
|
+
# call with a 302 to a sign-in page the caller cannot follow.
|
|
125
|
+
def clowk_api_only?
|
|
126
|
+
defined?(ActionController::API) && is_a?(ActionController::API)
|
|
127
|
+
end
|
|
128
|
+
|
|
122
129
|
def clowk_api_request?
|
|
123
|
-
clowk_session_store.nil? || request.format.json?
|
|
130
|
+
clowk_api_only? || clowk_session_store.nil? || request.format.json?
|
|
124
131
|
end
|
|
125
132
|
|
|
126
133
|
def clowk_handle_unauthenticated
|
|
@@ -139,18 +146,24 @@ module Clowk
|
|
|
139
146
|
end
|
|
140
147
|
end
|
|
141
148
|
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
#
|
|
149
|
+
# nil in API-only controllers. Not because `session` raises there — it does
|
|
150
|
+
# not, see clowk_api_only? — but because whatever it hands back writes to
|
|
151
|
+
# nowhere, and callers branch on this to decide whether persisting is worth
|
|
152
|
+
# doing at all.
|
|
145
153
|
def clowk_session_store
|
|
146
154
|
return @clowk_session_store if defined?(@clowk_session_store)
|
|
147
155
|
|
|
148
|
-
@clowk_session_store =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
@clowk_session_store =
|
|
157
|
+
if clowk_api_only?
|
|
158
|
+
nil
|
|
159
|
+
else
|
|
160
|
+
begin
|
|
161
|
+
store = session
|
|
162
|
+
store.respond_to?(:[]) ? store : nil
|
|
163
|
+
rescue
|
|
164
|
+
nil
|
|
165
|
+
end
|
|
166
|
+
end
|
|
154
167
|
end
|
|
155
168
|
|
|
156
169
|
def clowk_cookie_jar
|
data/lib/clowk/version.rb
CHANGED