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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bda08956b38e4898a4230985bf562a70a9ecf50a
4
- data.tar.gz: 6a3e4ebddeafa5208a32babee28ab3e0fea06d31
3
+ metadata.gz: e40ddeb33b7115d793467990fe4234e232d1e2cd
4
+ data.tar.gz: d3dc48457dd8ecf3b52260a72be47e0b89246246
5
5
  SHA512:
6
- metadata.gz: e5d2fec915ce81fd648339e7f6aefc5f12dca26df92b84c20116f569c3b3d99ea657e2bbd7325e2cb272398c31b1e4211a08aeedcf6e3ecadee06e3a3c3ceb98
7
- data.tar.gz: 2232cd7f89419f33b95a9ee0c8f51c46bb7f5de7d1666ff098dc953714383b8a9906103f61689edf6bb02028ee05dd16f9a47ca28a6b61abaf05f4837966f37a
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.1'
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: err, submit_path: env['REQUEST_URI'],
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)
@@ -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
- post('/', {'cerberus_login' => 'fake_login', 'cerberus_pass' => 'fake_pass'})
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cerberus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Riga