lockup 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmFiY2Y3YTIxODM0MzJmM2E2MzE2ZDYzYjdiZjIyMWUyNTQ1Njc0Mg==
4
+ ZWY1MWUyNTJiZWI1ZjNhY2JjNWQzNWU2NTU1ZTJmOTYxNTI0NWM1OA==
5
5
  data.tar.gz: !binary |-
6
- ODY2ZjhlMGZkNjgxZTZkMjkyYzQ3NDcwZGQyZjg5NjhhZTgyODZlYw==
6
+ ODMwZTVmNWNkYzQ0NmYwNmE5ZTA1OTJhNGM0MGRlODY4OTIyMjQ4Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWVkNmE0MWE1NjUxYmE3NGI3MzRlNzA5MTFlYTcxYzBhNzM1ZTQ2M2M3OWFm
10
- NTM4NDY3NzM3YzQ0MGI1ZDMyZmU2NGNjMjZmOTgyYWQ3ODRkNmQyODVlZjFm
11
- N2RjNjMxMmJjMGRlMDgwODMwZmM3ODAxNmYwOTBlODNiMDRjNjA=
9
+ MGRlMjM5NzRiYzYyYzg5MzkzN2RkNzM0Y2ViNDcyMDRiMTQ4YjcyZDNlNjg4
10
+ M2Y1M2RiMDZkNjM1MTMwYTgyYWRjY2RhMzc3ZmM2Mjk1NDliN2FjNTM1Yzlj
11
+ MGEzM2Y2NzM1MWZmZWYwMjkyNDI0YTExYjcwOWQxNDI4OGZlOWE=
12
12
  data.tar.gz: !binary |-
13
- Yzg2N2I5ZjYyZjQ2MmQyYzAzNjRmZTUzOTg4NjM2NWZkZmZlYTg4OTlkOTI3
14
- MGUxNGJkZjU2YTczMzY1NzFiMWVlZTBlZTJjYmQ1NzUwYTNlNGExZjYxNTQ4
15
- ZTVmYjAzOGQ4ZTY0MjU0YTZkMmUwNmY5MmUwZjkyZTRlZGZmN2I=
13
+ YzQ3NzBlOTk4YjkyNzQ2ODA0NTljMGVhOTUyMGQ5OGY2OGIwN2RkZWYyNTA5
14
+ ZDIxZThkNWJiNjA1MmVlZTU3N2U0ZDk0ZmU4NDhkZjBhY2MxZmJlMzQxY2Zm
15
+ ZmJhNTBlNWQ2ZDg3Mjc1YjViM2IwMTk3NTkzZDVlY2I3Y2E5MTQ=
data/README.md CHANGED
@@ -42,9 +42,9 @@ If you’re using Rails 4.1 or greater, you can add your Lockup Codeword via Rai
42
42
 
43
43
  If you’re using [Figaro](https://github.com/laserlemon/figaro), set your Lockup codeword and hint (optional) in your application.yml file:
44
44
 
45
- LOCKUP_CODEWORD: 'love'
45
+ lockup_codeword: 'love'
46
46
 
47
- LOCKUP_HINT: 'Pepé Le Pew'
47
+ lockup_hint: 'Pepé Le Pew'
48
48
 
49
49
  **Codewords are not case-sensitive, by design. Keep it simple.**
50
50
 
@@ -8,7 +8,7 @@ module Lockup
8
8
  unless user_agent.match(/crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/)
9
9
  @codeword = params[:lockup_codeword].to_s.downcase
10
10
  @return_to = params[:return_to]
11
- if @codeword == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && @codeword == Rails.application.secrets.lockup_codeword.to_s.downcase)
11
+ if @codeword == lockup_codeword
12
12
  set_cookie
13
13
  run_redirect
14
14
  end
@@ -19,7 +19,7 @@ module Lockup
19
19
  if params[:lockup].present? && params[:lockup].respond_to?(:'[]')
20
20
  @codeword = params[:lockup][:codeword].to_s.downcase
21
21
  @return_to = params[:lockup][:return_to]
22
- if @codeword == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && @codeword == Rails.application.secrets.lockup_codeword.to_s.downcase)
22
+ if @codeword == lockup_codeword
23
23
  set_cookie
24
24
  run_redirect
25
25
  else
@@ -0,0 +1,25 @@
1
+ module Lockup
2
+ module LockupHelper
3
+
4
+ def lockup_hint_present?
5
+ if ENV["LOCKUP_HINT"].present? || ENV["lockup_hint"].present? || Figaro.env.lockup_hint.present? || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_hint.present?)
6
+ true
7
+ else
8
+ false
9
+ end
10
+ end
11
+
12
+ def lockup_hint_display
13
+ if ENV["LOCKUP_HINT"].present?
14
+ ENV["LOCKUP_HINT"].to_s
15
+ elsif ENV["lockup_hint"].present?
16
+ ENV["lockup_hint"].to_s
17
+ elsif Figaro.env.lockup_hint.present?
18
+ Figaro.env.lockup_hint.to_s
19
+ elsif (Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_hint.present?
20
+ Rails.application.secrets.lockup_hint.to_s
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -13,9 +13,9 @@
13
13
  <p><%= form.password_field "codeword", value: @codeword, class: 'nope' %></p>
14
14
  <% end %>
15
15
 
16
- <% if ENV["LOCKUP_HINT"].present? || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_hint.present?) %>
16
+ <% if lockup_hint_present? %>
17
17
  <p id='hint_icon'>?</p>
18
- <p id='hint'><%= ENV["LOCKUP_HINT"].present? ? ENV["LOCKUP_HINT"] : Rails.application.secrets.lockup_hint %></p>
18
+ <p id='hint'><%= lockup_hint_display %></p>
19
19
  <% end %>
20
20
 
21
21
  <% if params[:return_to].present? %>
data/lib/lockup.rb CHANGED
@@ -10,9 +10,9 @@ module Lockup
10
10
  private
11
11
 
12
12
  def check_for_lockup
13
- if ENV["LOCKUP_CODEWORD"].present? || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_codeword.present?)
13
+ if lockup_codeword_present?
14
14
  if cookies[:lockup].present?
15
- if cookies[:lockup] == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && cookies[:lockup] == Rails.application.secrets.lockup_codeword.to_s.downcase)
15
+ if cookies[:lockup] == lockup_codeword
16
16
  return
17
17
  else
18
18
  redirect_to lockup.unlock_path(return_to: request.fullpath.split('?lockup_codeword')[0], lockup_codeword: params[:lockup_codeword])
@@ -23,4 +23,24 @@ module Lockup
23
23
  end
24
24
  end
25
25
 
26
+ def lockup_codeword_present?
27
+ if ENV["LOCKUP_CODEWORD"].present? || ENV["lockup_codeword"].present? || Figaro.env.lockup_codeword.present? || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_codeword.present?)
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
33
+
34
+ def lockup_codeword
35
+ if ENV["LOCKUP_CODEWORD"].present?
36
+ ENV["LOCKUP_CODEWORD"].to_s.downcase
37
+ elsif ENV["lockup_codeword"].present?
38
+ ENV["lockup_codeword"].to_s.downcase
39
+ elsif Figaro.env.lockup_codeword.present?
40
+ Figaro.env.lockup_codeword.to_s.downcase
41
+ elsif (Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_codeword.present?
42
+ Rails.application.secrets.lockup_codeword.to_s.downcase
43
+ end
44
+ end
45
+
26
46
  end
@@ -1,3 +1,3 @@
1
1
  module Lockup
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - gb Studio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - app/controllers/lockup/application_controller.rb
88
88
  - app/controllers/lockup/lockup_controller.rb
89
89
  - app/helpers/lockup/application_helper.rb
90
+ - app/helpers/lockup/lockup_helper.rb
90
91
  - app/views/layouts/lockup/_inline_css.html.erb
91
92
  - app/views/layouts/lockup/_inline_js.html.erb
92
93
  - app/views/layouts/lockup/application.html.erb