sudo_rails 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 4b5f63db43fde756597153993a5ec14de3a2391e048fc221fc8630ca440d1688
4
- data.tar.gz: 5be8d33df45adc1f9314555cbb65090cac0a0f8cc25a5fe5c114a67b31b84256
3
+ metadata.gz: b068a949cf40f7c80340a50eb88c884b46b97ce172f06501f74905df4cdf41b6
4
+ data.tar.gz: e8acc824d2c985f6e1c02ea9398a3a1d3e9a1ccb3ceb53e6cc9fc6bfc59247fe
5
5
  SHA512:
6
- metadata.gz: 7a36cf5217082dc574ebebd6bca0d8ee98bd2576db780ca19fe94af6be9bf421d077687756ae0539a16dfefe9ac58388d7c03832c48a0abc0b0b34954180c1af
7
- data.tar.gz: 14ab4140a84df2017818dd98cdc405d77d388becf5a65a8b633a61390ca37dc0f8029add4f1bf86de153e1869c7b8efa54619d0ba9f8012f9493ecb72130ec75
6
+ metadata.gz: 9be87bdf8590b2b8018291a972f3cc9604457469d665ad42a7ef83108c3976fca62fda3c83ac4ccda374e0f4da65e3c67f3c8d2362314274f9451af4ad74a3f6
7
+ data.tar.gz: 367955d60d36a62227314aa6a65b04bb1841de39fe40062e919e92e260f7f5be7a238fd79548dc2e741fe72cc2d0cecfa646a406e6e17d4636297c798b41f400
@@ -4,7 +4,7 @@ module SudoRails
4
4
 
5
5
  def confirm
6
6
  if request.post? && SudoRails.confirm?(self, params[:password])
7
- session[:sudo_rails_session] = Time.zone.now
7
+ session[:sudo_rails_session] = Time.zone.now.to_s
8
8
  redirect_to params[:target_path]
9
9
  else
10
10
  render 'sudo_rails/confirm_form', layout: SudoRails.get_layout
@@ -3,18 +3,10 @@ module SudoRails
3
3
  def sudo(options = {})
4
4
  before_action(options) do
5
5
  next unless SudoRails.enabled
6
- next if SudoRails::ControllerExt.valid_sudo_session?(session[:sudo_rails_session])
6
+ next if SudoRails.valid_sudo_session?(session[:sudo_rails_session])
7
7
 
8
8
  render 'sudo_rails/confirm_form', layout: SudoRails.get_layout
9
9
  end
10
10
  end
11
-
12
- private
13
-
14
- def self.valid_sudo_session?(started_at)
15
- return false unless started_at
16
-
17
- Time.parse(started_at) + SudoRails.sudo_session_duration > Time.zone.now
18
- end
19
11
  end
20
12
  end
@@ -1,3 +1,3 @@
1
1
  module SudoRails
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/sudo_rails.rb CHANGED
@@ -30,6 +30,12 @@ module SudoRails
30
30
 
31
31
  strategy.call(context, password)
32
32
  end
33
+
34
+ def valid_sudo_session?(started_at)
35
+ return false unless started_at
36
+
37
+ DateTime.parse(started_at) + sudo_session_duration > Time.zone.now
38
+ end
33
39
  end
34
40
 
35
41
  self.enabled = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sudo_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets