devise 1.1.9 → 1.2.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (121) hide show
  1. data/CHANGELOG.rdoc +34 -26
  2. data/README.rdoc +134 -100
  3. data/app/controllers/devise/confirmations_controller.rb +1 -1
  4. data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
  5. data/app/controllers/devise/passwords_controller.rb +1 -1
  6. data/app/controllers/devise/registrations_controller.rb +59 -6
  7. data/app/controllers/devise/sessions_controller.rb +3 -2
  8. data/app/controllers/devise/unlocks_controller.rb +1 -1
  9. data/app/helpers/devise_helper.rb +4 -2
  10. data/app/mailers/devise/mailer.rb +27 -10
  11. data/app/views/devise/confirmations/new.html.erb +1 -1
  12. data/app/views/devise/passwords/edit.html.erb +2 -2
  13. data/app/views/devise/passwords/new.html.erb +1 -1
  14. data/app/views/devise/registrations/edit.html.erb +1 -1
  15. data/app/views/devise/registrations/new.html.erb +1 -1
  16. data/app/views/devise/sessions/new.html.erb +1 -1
  17. data/app/views/devise/shared/_links.erb +6 -0
  18. data/app/views/devise/unlocks/new.html.erb +1 -1
  19. data/config/locales/en.yml +9 -2
  20. data/lib/devise.rb +116 -58
  21. data/lib/devise/controllers/helpers.rb +103 -107
  22. data/lib/devise/controllers/internal_helpers.rb +23 -7
  23. data/lib/devise/controllers/scoped_views.rb +4 -6
  24. data/lib/devise/controllers/url_helpers.rb +3 -5
  25. data/lib/devise/encryptors/base.rb +1 -1
  26. data/lib/devise/encryptors/restful_authentication_sha1.rb +4 -4
  27. data/lib/devise/failure_app.rb +29 -21
  28. data/lib/devise/hooks/forgetable.rb +2 -1
  29. data/lib/devise/hooks/rememberable.rb +11 -9
  30. data/lib/devise/mapping.rb +12 -5
  31. data/lib/devise/models.rb +0 -14
  32. data/lib/devise/models/authenticatable.rb +40 -30
  33. data/lib/devise/models/confirmable.rb +11 -15
  34. data/lib/devise/models/database_authenticatable.rb +23 -35
  35. data/lib/devise/models/encryptable.rb +65 -0
  36. data/lib/devise/models/lockable.rb +8 -7
  37. data/lib/devise/models/omniauthable.rb +23 -0
  38. data/lib/devise/models/recoverable.rb +5 -3
  39. data/lib/devise/models/registerable.rb +13 -0
  40. data/lib/devise/models/rememberable.rb +38 -30
  41. data/lib/devise/models/timeoutable.rb +20 -3
  42. data/lib/devise/models/token_authenticatable.rb +19 -7
  43. data/lib/devise/models/validatable.rb +16 -4
  44. data/lib/devise/modules.rb +15 -8
  45. data/lib/devise/omniauth.rb +47 -0
  46. data/lib/devise/omniauth/config.rb +30 -0
  47. data/lib/devise/omniauth/test_helpers.rb +57 -0
  48. data/lib/devise/omniauth/url_helpers.rb +29 -0
  49. data/lib/devise/orm/active_record.rb +2 -0
  50. data/lib/devise/orm/mongoid.rb +4 -2
  51. data/lib/devise/rails.rb +26 -46
  52. data/lib/devise/rails/routes.rb +64 -20
  53. data/lib/devise/rails/warden_compat.rb +18 -20
  54. data/lib/devise/schema.rb +13 -14
  55. data/lib/devise/strategies/authenticatable.rb +33 -7
  56. data/lib/devise/strategies/database_authenticatable.rb +1 -1
  57. data/lib/devise/strategies/rememberable.rb +1 -1
  58. data/lib/devise/strategies/token_authenticatable.rb +6 -2
  59. data/lib/devise/test_helpers.rb +11 -1
  60. data/lib/devise/version.rb +1 -1
  61. data/lib/generators/active_record/templates/migration.rb +1 -0
  62. data/lib/generators/devise/orm_helpers.rb +3 -2
  63. data/lib/generators/templates/devise.rb +70 -39
  64. data/test/controllers/helpers_test.rb +43 -67
  65. data/test/controllers/internal_helpers_test.rb +29 -8
  66. data/test/controllers/url_helpers_test.rb +2 -1
  67. data/test/failure_app_test.rb +56 -21
  68. data/test/generators/generators_test_helper.rb +4 -0
  69. data/test/generators/install_generator_test.rb +14 -0
  70. data/test/generators/views_generator_test.rb +37 -0
  71. data/test/integration/authenticatable_test.rb +147 -62
  72. data/test/integration/database_authenticatable_test.rb +22 -0
  73. data/test/integration/http_authenticatable_test.rb +12 -2
  74. data/test/integration/omniauthable_test.rb +107 -0
  75. data/test/integration/recoverable_test.rb +39 -20
  76. data/test/integration/registerable_test.rb +30 -4
  77. data/test/integration/rememberable_test.rb +57 -34
  78. data/test/integration/timeoutable_test.rb +10 -1
  79. data/test/integration/token_authenticatable_test.rb +12 -17
  80. data/test/mailers/confirmation_instructions_test.rb +4 -0
  81. data/test/mailers/reset_password_instructions_test.rb +4 -0
  82. data/test/mailers/unlock_instructions_test.rb +4 -0
  83. data/test/mapping_test.rb +37 -3
  84. data/test/models/confirmable_test.rb +3 -3
  85. data/test/models/database_authenticatable_test.rb +14 -71
  86. data/test/models/encryptable_test.rb +65 -0
  87. data/test/models/lockable_test.rb +17 -1
  88. data/test/models/recoverable_test.rb +17 -0
  89. data/test/models/rememberable_test.rb +186 -125
  90. data/test/models/token_authenticatable_test.rb +1 -13
  91. data/test/models_test.rb +5 -5
  92. data/test/omniauth/url_helpers_test.rb +47 -0
  93. data/test/rails_app/app/active_record/admin.rb +4 -1
  94. data/test/rails_app/app/active_record/user.rb +5 -4
  95. data/test/rails_app/app/controllers/{sessions_controller.rb → admins/sessions_controller.rb} +1 -1
  96. data/test/rails_app/app/controllers/home_controller.rb +9 -0
  97. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +7 -0
  98. data/test/rails_app/app/mongoid/admin.rb +4 -1
  99. data/test/rails_app/app/mongoid/shim.rb +16 -3
  100. data/test/rails_app/app/mongoid/user.rb +5 -5
  101. data/test/rails_app/config/initializers/devise.rb +52 -28
  102. data/test/rails_app/config/routes.rb +14 -6
  103. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +21 -17
  104. data/test/rails_app/db/schema.rb +17 -51
  105. data/test/rails_app/lib/shared_admin.rb +9 -0
  106. data/test/rails_app/lib/shared_user.rb +23 -0
  107. data/test/routes_test.rb +42 -9
  108. data/test/support/integration.rb +3 -3
  109. data/test/support/webrat/integrations/rails.rb +7 -0
  110. data/test/test_helper.rb +2 -0
  111. data/test/test_helpers_test.rb +29 -0
  112. metadata +60 -30
  113. data/Gemfile +0 -27
  114. data/Gemfile.lock +0 -115
  115. data/Rakefile +0 -55
  116. data/TODO +0 -3
  117. data/lib/devise/encryptors/bcrypt.rb +0 -19
  118. data/lib/generators/devise_install_generator.rb +0 -4
  119. data/lib/generators/devise_views_generator.rb +0 -4
  120. data/test/indifferent_hash.rb +0 -33
  121. data/test/support/test_silencer.rb +0 -5
data/Gemfile DELETED
@@ -1,27 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem "rails", "~> 3.0.4"
6
-
7
- group :test do
8
- gem "webrat", "0.7.2", :require => false
9
- gem "mocha", :require => false
10
- end
11
-
12
- platforms :jruby do
13
- gem 'activerecord-jdbcsqlite3-adapter'
14
- end
15
-
16
- platforms :ruby do
17
- group :test do
18
- gem "sqlite3-ruby"
19
- gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'
20
- end
21
-
22
- group :mongoid do
23
- gem "mongo", "1.1.2"
24
- gem "mongoid", "2.0.0.beta.20"
25
- gem "bson_ext", "1.1.2"
26
- end
27
- end
@@ -1,115 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- devise (1.1.8)
5
- bcrypt-ruby (~> 2.1.2)
6
- warden (~> 1.0.2)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- abstract (1.0.0)
12
- actionmailer (3.0.4)
13
- actionpack (= 3.0.4)
14
- mail (~> 2.2.15)
15
- actionpack (3.0.4)
16
- activemodel (= 3.0.4)
17
- activesupport (= 3.0.4)
18
- builder (~> 2.1.2)
19
- erubis (~> 2.6.6)
20
- i18n (~> 0.4)
21
- rack (~> 1.2.1)
22
- rack-mount (~> 0.6.13)
23
- rack-test (~> 0.5.7)
24
- tzinfo (~> 0.3.23)
25
- activemodel (3.0.4)
26
- activesupport (= 3.0.4)
27
- builder (~> 2.1.2)
28
- i18n (~> 0.4)
29
- activerecord (3.0.4)
30
- activemodel (= 3.0.4)
31
- activesupport (= 3.0.4)
32
- arel (~> 2.0.2)
33
- tzinfo (~> 0.3.23)
34
- activeresource (3.0.4)
35
- activemodel (= 3.0.4)
36
- activesupport (= 3.0.4)
37
- activesupport (3.0.4)
38
- arel (2.0.8)
39
- bcrypt-ruby (2.1.4)
40
- bson (1.1.2)
41
- bson_ext (1.1.2)
42
- builder (2.1.2)
43
- columnize (0.3.2)
44
- erubis (2.6.6)
45
- abstract (>= 1.0.0)
46
- i18n (0.5.0)
47
- linecache (0.43)
48
- mail (2.2.15)
49
- activesupport (>= 2.3.6)
50
- i18n (>= 0.4.0)
51
- mime-types (~> 1.16)
52
- treetop (~> 1.4.8)
53
- mime-types (1.16)
54
- mocha (0.9.9)
55
- rake
56
- mongo (1.1.2)
57
- bson (>= 1.1.1)
58
- mongoid (2.0.0.beta.20)
59
- activemodel (~> 3.0)
60
- mongo (~> 1.1)
61
- tzinfo (~> 0.3.22)
62
- will_paginate (~> 3.0.pre)
63
- nokogiri (1.4.4)
64
- polyglot (0.3.1)
65
- rack (1.2.1)
66
- rack-mount (0.6.13)
67
- rack (>= 1.0.0)
68
- rack-test (0.5.7)
69
- rack (>= 1.0)
70
- rails (3.0.4)
71
- actionmailer (= 3.0.4)
72
- actionpack (= 3.0.4)
73
- activerecord (= 3.0.4)
74
- activeresource (= 3.0.4)
75
- activesupport (= 3.0.4)
76
- bundler (~> 1.0)
77
- railties (= 3.0.4)
78
- railties (3.0.4)
79
- actionpack (= 3.0.4)
80
- activesupport (= 3.0.4)
81
- rake (>= 0.8.7)
82
- thor (~> 0.14.4)
83
- rake (0.8.7)
84
- ruby-debug (0.10.4)
85
- columnize (>= 0.1)
86
- ruby-debug-base (~> 0.10.4.0)
87
- ruby-debug-base (0.10.4)
88
- linecache (>= 0.3)
89
- sqlite3-ruby (1.3.2)
90
- thor (0.14.6)
91
- treetop (1.4.9)
92
- polyglot (>= 0.3.1)
93
- tzinfo (0.3.24)
94
- warden (1.0.3)
95
- rack (>= 1.0.0)
96
- webrat (0.7.2)
97
- nokogiri (>= 1.2.0)
98
- rack (>= 1.0)
99
- rack-test (>= 0.5.3)
100
- will_paginate (3.0.pre2)
101
-
102
- PLATFORMS
103
- ruby
104
-
105
- DEPENDENCIES
106
- activerecord-jdbcsqlite3-adapter
107
- bson_ext (= 1.1.2)
108
- devise!
109
- mocha
110
- mongo (= 1.1.2)
111
- mongoid (= 2.0.0.beta.20)
112
- rails (~> 3.0.4)
113
- ruby-debug (>= 0.10.3)
114
- sqlite3-ruby
115
- webrat (= 0.7.2)
data/Rakefile DELETED
@@ -1,55 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'rake'
4
- require 'rake/testtask'
5
- require 'rake/rdoctask'
6
- require File.join(File.dirname(__FILE__), 'lib', 'devise', 'version')
7
-
8
- desc 'Default: run tests for all ORMs.'
9
- task :default => :pre_commit
10
-
11
- desc 'Run Devise tests for all ORMs.'
12
- task :pre_commit do
13
- Dir[File.join(File.dirname(__FILE__), 'test', 'orm', '*.rb')].each do |file|
14
- orm = File.basename(file).split(".").first
15
- system "rake test DEVISE_ORM=#{orm}"
16
- end
17
- end
18
-
19
- desc 'Run Devise unit tests.'
20
- Rake::TestTask.new(:test) do |t|
21
- t.libs << 'lib'
22
- t.libs << 'test'
23
- t.pattern = 'test/**/*_test.rb'
24
- t.verbose = true
25
- end
26
-
27
- desc 'Generate documentation for Devise.'
28
- Rake::RDocTask.new(:rdoc) do |rdoc|
29
- rdoc.rdoc_dir = 'rdoc'
30
- rdoc.title = 'Devise'
31
- rdoc.options << '--line-numbers' << '--inline-source'
32
- rdoc.rdoc_files.include('README.rdoc')
33
- rdoc.rdoc_files.include('lib/**/*.rb')
34
- end
35
-
36
- begin
37
- require 'jeweler'
38
- Jeweler::Tasks.new do |s|
39
- s.name = "devise"
40
- s.version = Devise::VERSION.dup
41
- s.summary = "Flexible authentication solution for Rails with Warden"
42
- s.email = "contact@plataformatec.com.br"
43
- s.homepage = "http://github.com/plataformatec/devise"
44
- s.description = "Flexible authentication solution for Rails with Warden"
45
- s.authors = ['José Valim', 'Carlos Antônio']
46
- s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
47
- s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
48
- s.add_dependency("warden", "~> 1.0.2")
49
- s.add_dependency("bcrypt-ruby", "~> 2.1.2")
50
- end
51
-
52
- Jeweler::GemcutterTasks.new
53
- rescue LoadError
54
- puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
55
- end
data/TODO DELETED
@@ -1,3 +0,0 @@
1
- * Move integration tests to Capybara
2
- * Better ORM integration
3
- * Extract activatable models tests from confirmable
@@ -1,19 +0,0 @@
1
- require "bcrypt"
2
-
3
- module Devise
4
- module Encryptors
5
- # = BCrypt
6
- # Uses the BCrypt hash algorithm to encrypt passwords.
7
- class Bcrypt < Base
8
- # Gererates a default password digest based on stretches, salt, pepper and the
9
- # incoming password. We don't strech it ourselves since BCrypt does so internally.
10
- def self.digest(password, stretches, salt, pepper)
11
- ::BCrypt::Engine.hash_secret([password, pepper].join, salt, stretches)
12
- end
13
-
14
- def self.salt(stretches)
15
- ::BCrypt::Engine.generate_salt(stretches)
16
- end
17
- end
18
- end
19
- end
@@ -1,4 +0,0 @@
1
- # Remove this file after deprecation
2
- if caller.none? { |l| l =~ %r{lib/rails/generators\.rb:(\d+):in `lookup!'$} }
3
- warn "[WARNING] `rails g devise_install` is deprecated, please use `rails g devise:install` instead."
4
- end
@@ -1,4 +0,0 @@
1
- # Remove this file after deprecation
2
- if caller.none? { |l| l =~ %r{lib/rails/generators\.rb:(\d+):in `lookup!'$} }
3
- warn "[WARNING] `rails g devise_views` is deprecated, please use `rails g devise:views` instead."
4
- end
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
-
3
- class IndifferentHashTest < ActiveSupport::TestCase
4
- setup do
5
- @hash = Devise::IndifferentHash.new
6
- end
7
-
8
- test "it overwrites getter and setter" do
9
- @hash[:foo] = "bar"
10
- assert_equal "bar", @hash["foo"]
11
- assert_equal "bar", @hash[:foo]
12
-
13
- @hash["foo"] = "baz"
14
- assert_equal "baz", @hash["foo"]
15
- assert_equal "baz", @hash[:foo]
16
- end
17
-
18
- test "it overwrites update" do
19
- @hash.update :foo => "bar"
20
- assert_equal "bar", @hash["foo"]
21
- assert_equal "bar", @hash[:foo]
22
-
23
- @hash.update "foo" => "baz"
24
- assert_equal "baz", @hash["foo"]
25
- assert_equal "baz", @hash[:foo]
26
- end
27
-
28
- test "it returns a Hash on to_hash" do
29
- @hash[:foo] = "bar"
30
- assert_equal Hash["foo", "bar"], @hash.to_hash
31
- assert_kind_of Hash, @hash.to_hash
32
- end
33
- end if defined?(Devise::IndifferentHash)
@@ -1,5 +0,0 @@
1
- module Devise
2
- module TestSilencer
3
- def test(*args, &block); end
4
- end
5
- end