authpwn_rails 0.7.1 → 0.7.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{authpwn_rails}
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
12
- s.date = %q{2011-03-04}
12
+ s.date = %q{2011-03-06}
13
13
  s.description = %q{Works with Facebook.}
14
14
  s.email = %q{victor@costan.us}
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  ]
60
60
  s.homepage = %q{http://github.com/pwnall/authpwn_rails}
61
61
  s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.5.3}
62
+ s.rubygems_version = %q{1.6.0}
63
63
  s.summary = %q{User authentication for Rails 3 applications.}
64
64
  s.test_files = [
65
65
  "test/cookie_controller_test.rb",
@@ -64,12 +64,22 @@ module ControllerInstanceMethods
64
64
  # If no user is logged in, the user is redirected to session/new, and the
65
65
  # current request's URL is saved in flash[:auth_redirect_url].
66
66
  def bounce_user(redirect_url = request.url)
67
- @redirect_url = redirect_url
68
- if current_user
69
- render 'session/forbidden', :status => :forbidden
70
- else
71
- flash[:auth_redirect_url] = redirect_url
72
- render 'session/forbidden', :status => :forbidden
67
+ # NOTE: this is tested in CookieControllerTest
68
+ respond_to do |format|
69
+ format.html do
70
+ @redirect_url = redirect_url
71
+ if current_user
72
+ render 'session/forbidden', :status => :forbidden
73
+ else
74
+ flash[:auth_redirect_url] = redirect_url
75
+ render 'session/forbidden', :status => :forbidden
76
+ end
77
+ end
78
+ format.json do
79
+ message = current_user ? "You're not allowed to access that" :
80
+ 'Please sign in'
81
+ render :json => { :error => message }
82
+ end
73
83
  end
74
84
  end
75
85
  end
@@ -49,6 +49,14 @@ class CookieControllerTest < ActionController::TestCase
49
49
  assert_response :forbidden
50
50
  assert_template 'session/forbidden'
51
51
  end
52
+
53
+ test "valid user_id bounced in json" do
54
+ set_session_current_user @user
55
+ get :bouncer, :format => 'json'
56
+ assert_response :ok
57
+ data = ActiveSupport::JSON.decode response.body
58
+ assert_match(/not allowed/i, data['error'])
59
+ end
52
60
 
53
61
  test "no user_id bounced" do
54
62
  get :bouncer
@@ -58,4 +66,11 @@ class CookieControllerTest < ActionController::TestCase
58
66
 
59
67
  assert_select 'script', %r/.*window.location.*#{new_session_path}.*/
60
68
  end
69
+
70
+ test "no user_id bounced in json" do
71
+ get :bouncer, :format => 'json'
72
+ assert_response :ok
73
+ data = ActiveSupport::JSON.decode response.body
74
+ assert_match(/sign in/i, data['error'])
75
+ end
61
76
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authpwn_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Costan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-04 00:00:00 -05:00
18
+ date: 2011-03-06 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements: []
146
146
 
147
147
  rubyforge_project:
148
- rubygems_version: 1.5.3
148
+ rubygems_version: 1.6.0
149
149
  signing_key:
150
150
  specification_version: 3
151
151
  summary: User authentication for Rails 3 applications.