sudo_rails 0.2.0 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b068a949cf40f7c80340a50eb88c884b46b97ce172f06501f74905df4cdf41b6
|
4
|
+
data.tar.gz: e8acc824d2c985f6e1c02ea9398a3a1d3e9a1ccb3ceb53e6cc9fc6bfc59247fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/sudo_rails/version.rb
CHANGED
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
|