sudo_rails 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +9 -1
- data/app/assets/stylesheets/sudo_rails/application.scss +17 -2
- data/app/controllers/sudo_rails/application_controller.rb +4 -3
- data/app/views/layouts/sudo_rails/application.html.erb +4 -1
- data/app/views/sudo_rails/_flash_alert.html.erb +5 -0
- data/app/views/sudo_rails/_inject_custom_styles.html.erb +6 -1
- data/app/views/sudo_rails/confirm_form.html.erb +7 -5
- data/config/locales/en.yml +1 -0
- data/lib/sudo_rails.rb +1 -0
- data/lib/sudo_rails/engine.rb +1 -1
- data/lib/sudo_rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cde0b8c08400028fee437eac2352ebfeb2676209ef14fc55ce1da3f407a10072
|
4
|
+
data.tar.gz: 5d150b96bc25cc3366d2d498a4883a3e0a75c56b80b400b35f985791eb27aca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7fd91b40ad9d1659943ad5ebcb2a160462aa1bc019d1c332a7f36bf82cd7ea404336523c14e4b40d0ee6d6efafb61433407e6d6160e653da40a4673e13d9b0
|
7
|
+
data.tar.gz: f16c2166aea71899e9b7c8f051ee991e9bbe1e17a18366b16db48b55f029f4a76124f5bccbdf4d02626a4526f8f7d620a5bdced0370caaff5e27383567d10181
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Sudo Rails
|
2
2
|
|
3
3
|
[![Gem](https://img.shields.io/gem/v/sudo_rails.svg?style=flat-square)](https://rubygems.org/gems/sudo_rails)
|
4
|
-
[![Build Status](https://travis-ci.
|
4
|
+
[![Build Status](https://travis-ci.com/markets/sudo_rails.svg?branch=master)](https://travis-ci.com/markets/sudo_rails)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/322350adc7ab052beccb/maintainability)](https://codeclimate.com/github/markets/sudo_rails/maintainability)
|
6
6
|
|
7
7
|
> Sudo mode for your Rails controllers
|
@@ -71,12 +71,20 @@ SudoRails.setup do |config|
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
### Sudo sessions
|
75
|
+
|
76
|
+
Using the `sudo_session_duration` option you are able to configure the `sudo` session duration (30 minutes by default).
|
77
|
+
|
78
|
+
If you set it to `nil`, your `sudo` session won't expire automatically and you will have to do it manually by using the `reset_sudo_session!` helper.
|
79
|
+
|
74
80
|
### Styling
|
75
81
|
|
76
82
|
Using the `custom_logo`, `primary_color` and `background_color` options, you can customize the confirmation page. In case you want full control of the styles, you can use your own layout (and consequently your own styles too) using the `layout` option.
|
77
83
|
|
78
84
|
See some [examples here](support/images/).
|
79
85
|
|
86
|
+
**NOTE** If you are using your own layout, don't forget to render the flash messages in that layout. You can do something like [this](app/views/sudo_rails/_flash_alert.html.erb).
|
87
|
+
|
80
88
|
### Confirmation strategy
|
81
89
|
|
82
90
|
You should define how to validate the password using the `confirm_strategy` option. It must be a `lambda`, which will receive 2 arguments: the controller instance (`context`) and the password from the user.
|
@@ -2,13 +2,21 @@ body {
|
|
2
2
|
text-align: center;
|
3
3
|
font-family: Helvetica, Arial, sans-serif;
|
4
4
|
background-color: #ececec;
|
5
|
-
|
5
|
+
margin: 0 auto;
|
6
6
|
}
|
7
7
|
|
8
8
|
a {
|
9
9
|
color: #000;
|
10
10
|
}
|
11
11
|
|
12
|
+
input {
|
13
|
+
-webkit-appearance: none;
|
14
|
+
}
|
15
|
+
|
16
|
+
.sudo-container {
|
17
|
+
transform: translateY(25%);
|
18
|
+
}
|
19
|
+
|
12
20
|
.sudo-header {
|
13
21
|
margin: 2em auto;
|
14
22
|
|
@@ -50,4 +58,11 @@ a {
|
|
50
58
|
.sudo-tip {
|
51
59
|
margin-top: 2em;
|
52
60
|
font-size: 14px;
|
53
|
-
}
|
61
|
+
}
|
62
|
+
|
63
|
+
.sudo-alert {
|
64
|
+
background: #000;
|
65
|
+
color: #fff;
|
66
|
+
padding: 10px;
|
67
|
+
font-weight: bold;
|
68
|
+
}
|
@@ -3,12 +3,13 @@ module SudoRails
|
|
3
3
|
before_action :sudo_enabled?
|
4
4
|
|
5
5
|
def confirm
|
6
|
-
if
|
6
|
+
if SudoRails.confirm?(self, params[:password])
|
7
7
|
session[:sudo_session] = Time.zone.now.to_s
|
8
|
-
redirect_to params[:target_path]
|
9
8
|
else
|
10
|
-
|
9
|
+
flash[:alert] = I18n.t('sudo_rails.invalid_pass')
|
11
10
|
end
|
11
|
+
|
12
|
+
redirect_to params[:target_path]
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
@@ -4,6 +4,11 @@
|
|
4
4
|
background-color: <%= SudoRails.background_color %>;
|
5
5
|
color: <%= SudoRails.color_contrast(SudoRails.background_color) %>;
|
6
6
|
}
|
7
|
+
|
8
|
+
.sudo-alert {
|
9
|
+
background-color: <%= SudoRails.color_contrast(SudoRails.background_color) %>;
|
10
|
+
color: <%= SudoRails.background_color %>;
|
11
|
+
}
|
7
12
|
<% end %>
|
8
13
|
|
9
14
|
<% if SudoRails.primary_color.present? %>
|
@@ -16,4 +21,4 @@
|
|
16
21
|
color: <%= SudoRails.color_contrast(SudoRails.primary_color) %>;
|
17
22
|
}
|
18
23
|
<% end %>
|
19
|
-
</style>
|
24
|
+
</style>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<
|
1
|
+
<div class='sudo-header'>
|
2
2
|
<% if SudoRails.custom_logo %>
|
3
3
|
<%= image_tag SudoRails.custom_logo %>
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
<h2><%= t('sudo_rails.page_header') %></h2>
|
7
|
-
</
|
7
|
+
</div>
|
8
8
|
|
9
9
|
<div class='sudo-form'>
|
10
10
|
<%= form_tag '/sudo_rails/confirm' do |f| %>
|
@@ -18,6 +18,8 @@
|
|
18
18
|
<% end %>
|
19
19
|
</div>
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
<% unless SudoRails.sudo_session_duration.nil? %>
|
22
|
+
<div class='sudo-tip'>
|
23
|
+
<%= t('sudo_rails.tip', session_duration: time_ago_in_words(SudoRails.sudo_session_duration.ago)).html_safe %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
data/lib/sudo_rails.rb
CHANGED
data/lib/sudo_rails/engine.rb
CHANGED
data/lib/sudo_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sudo_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- app/assets/stylesheets/sudo_rails/application.scss
|
66
66
|
- app/controllers/sudo_rails/application_controller.rb
|
67
67
|
- app/views/layouts/sudo_rails/application.html.erb
|
68
|
+
- app/views/sudo_rails/_flash_alert.html.erb
|
68
69
|
- app/views/sudo_rails/_inject_custom_styles.html.erb
|
69
70
|
- app/views/sudo_rails/confirm_form.html.erb
|
70
71
|
- config/locales/en.yml
|