rack-cerberus 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/cerberus.rb +5 -3
- data/spec/rack_cerberus_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40ddeb33b7115d793467990fe4234e232d1e2cd
|
4
|
+
data.tar.gz: d3dc48457dd8ecf3b52260a72be47e0b89246246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7884094d857021dd3f8bb4c3ea56359ada28a030a1e9afde564dfa06b4b7a91fdec8553540c0ce38f734dc3c517ef7fc4a68a38f153781586ae92995d04293
|
7
|
+
data.tar.gz: 77d56f6ce8402060899e4b4bcd96e4cc62f1280c0d3ed50bfbcaaa6da59ae26aebb726e1bb725c224962ab6a427ba618c764a47f62447821179592972ec58509
|
data/lib/rack/cerberus.rb
CHANGED
@@ -4,7 +4,7 @@ module Rack
|
|
4
4
|
|
5
5
|
class Cerberus
|
6
6
|
|
7
|
-
VERSION = '1.0.
|
7
|
+
VERSION = '1.0.2'
|
8
8
|
|
9
9
|
class NoSessionError < RuntimeError; end
|
10
10
|
|
@@ -35,7 +35,6 @@ module Rack
|
|
35
35
|
req = Rack::Request.new(env)
|
36
36
|
login = req['cerberus_login']
|
37
37
|
pass = req['cerberus_pass']
|
38
|
-
err = req.post? ? "<p class='err'>Wrong login or password</p>" : ''
|
39
38
|
if ((env['rack.session'][@options[:session_key]]!=nil && env['PATH_INFO']!='/logout') || (login && pass && @block.call(login, pass, req)))
|
40
39
|
env['rack.session'][@options[:session_key]] ||= login
|
41
40
|
if env['PATH_INFO']=='/logout'
|
@@ -46,11 +45,14 @@ module Rack
|
|
46
45
|
@app.call(env)
|
47
46
|
end
|
48
47
|
else
|
48
|
+
if !login.nil? or !pass.nil?
|
49
|
+
error = "<p class='err'>Wrong login or password</p>"
|
50
|
+
end
|
49
51
|
env['rack.session'].delete(@options[:session_key])
|
50
52
|
[
|
51
53
|
401, {'Content-Type' => 'text/html'},
|
52
54
|
[AUTH_PAGE % @options.merge({
|
53
|
-
error:
|
55
|
+
error: error, submit_path: env['REQUEST_URI'],
|
54
56
|
request_method: req.request_method,
|
55
57
|
login: Rack::Utils.escape_html(login),
|
56
58
|
pass: Rack::Utils.escape_html(pass)
|
data/spec/rack_cerberus_spec.rb
CHANGED
@@ -49,7 +49,7 @@ RSpec.describe Rack::Cerberus do
|
|
49
49
|
|
50
50
|
context 'Login details are incorrect' do
|
51
51
|
it 'Stops requests' do
|
52
|
-
|
52
|
+
get('/', {'cerberus_login' => 'fake_login', 'cerberus_pass' => 'fake_pass'})
|
53
53
|
expect(last_response.status).to eq 401
|
54
54
|
expect(last_response.body).to include('Wrong login or password')
|
55
55
|
end
|