macmillan-utils 1.0.35 → 1.0.36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d1f96b3f99b5703f76145d41f69a05c60ee3c1f
4
- data.tar.gz: 967a40968eae7dec441b728c23734649c4043693
3
+ metadata.gz: ada5b04c123cce12dd5738f9e8c7339f79e7f1c7
4
+ data.tar.gz: 667f44687ebeabbf21cd0c804224cc5c2638d3eb
5
5
  SHA512:
6
- metadata.gz: 3c9bb4d6c825a9163fd017cf80bd18e7939861fbd58123245796efaf2aa472107d32c0fb9f3498ed57ecfa8ecf1a3d098fbcb5ac275a424dc2b8c16dd9179987
7
- data.tar.gz: 534ded1eb08362626ae117699ca4ad1dc1beab50b08df9872d0a7459b6b5a0c33d48ff0abe6d3ad9d924654bedf86c957cb5e4f101abb9fda54fd3af0eecefa8
6
+ metadata.gz: 53d2a756311cf92365cb8aa7fd82095e75a0776acb53b4446ffbdf43a7fbf94ea775e4e37a6787ede43edd8d711d9f2103c5e41c85a3667832ad7ba4887dd71d
7
+ data.tar.gz: d94fd2774200ed45426e3b3d3ca5c9638fa257a97c17abbbb55b3a70938676421eedf9f10b55aa5e23f88194bf7859a7d27172dee254dd1022b0e2e5cc385c72
@@ -14,10 +14,10 @@ module Macmillan
14
14
  end
15
15
 
16
16
  def call(env)
17
- request = Rack::Request.new(env)
17
+ @request = Rack::Request.new(env)
18
18
 
19
- if cookies_accepted?(request)
20
- redirect_back(request)
19
+ if cookies_accepted?(@request)
20
+ redirect_back(@request)
21
21
  else
22
22
  @app.call(env)
23
23
  end
@@ -26,9 +26,33 @@ module Macmillan
26
26
  private
27
27
 
28
28
  def cookies_accepted?(request)
29
- request.post? &&
30
- request.cookies[COOKIE] != 'accepted' &&
31
- request.params['cookies'] == 'accepted'
29
+
30
+ debug_log("request.post? IS #{request.post?.inspect}")
31
+ debug_log("request.cookies[#{COOKIE}] IS #{request.cookies[COOKIE]}")
32
+ debug_log("request.params['cookies'] IS #{request.params['cookies']}")
33
+
34
+ unless request.post?
35
+ debug_log("request.post? means pass-thru")
36
+ return false
37
+ end
38
+ unless request.cookies[COOKIE] != 'accepted'
39
+ debug_log("request.cookies[#{COOKIE}] means passthru")
40
+ return false
41
+ end
42
+ unless request.params['cookies'] == 'accepted'
43
+ debug_log("request.params['cookies'] means passthru")
44
+ return false
45
+ end
46
+ debug_log("About to set the acceptance cookie and redirect")
47
+ true
48
+ end
49
+
50
+ def debug_log(msg)
51
+ logger.debug("[Macmillan::Utils::Middleware::CookieMessage] #{msg}")
52
+ end
53
+
54
+ def logger
55
+ @logger ||= @request.logger || NullLogger.new
32
56
  end
33
57
 
34
58
  def redirect_back(request)
@@ -65,6 +89,12 @@ module Macmillan
65
89
  def internal_redirect?(request, uri)
66
90
  request.host == uri.host && request.port == uri.port
67
91
  end
92
+
93
+ class NullLogger
94
+ def method_missing(*args)
95
+ nil
96
+ end
97
+ end
68
98
  end
69
99
  end
70
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macmillan-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.35
4
+ version: 1.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Springer Nature
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler