devise 1.0.1 → 1.0.2

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.

@@ -1,3 +1,11 @@
1
+ == 1.0.2
2
+
3
+ * enhancements
4
+ * Allows you set mailer content type (by github.com/glennr)
5
+
6
+ * bug fix
7
+ * Uses the same content type as request on http authenticatable 401 responses
8
+
1
9
  == 1.0.1
2
10
 
3
11
  * enhancements
@@ -17,6 +25,7 @@
17
25
  * Added Http Basic Authentication support
18
26
  * Allow scoped_views to be customized per controller/mailer class
19
27
  * [#99] Allow authenticatable to used in change_table statements
28
+ * Add mailer_content_type configuration parameter (by github.com/glennr)
20
29
 
21
30
  == 0.9.2
22
31
 
@@ -30,17 +30,13 @@ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authenticati
30
30
 
31
31
  == Installation
32
32
 
33
- All gems are on gemcutter, so you need to add gemcutter to your sources if you haven't yet:
34
-
35
- sudo gem sources -a http://gemcutter.org/
36
-
37
- Install warden gem if you don't have it installed (requires 0.6.4 or higher):
33
+ Install warden gem if you don't have it installed:
38
34
 
39
35
  sudo gem install warden
40
36
 
41
37
  Install devise gem:
42
38
 
43
- sudo gem install devise
39
+ sudo gem install devise --version=1.0.1
44
40
 
45
41
  Configure warden and devise gems inside your app:
46
42
 
@@ -55,6 +51,10 @@ And you're ready to go. The generator will install an initializer which describe
55
51
 
56
52
  http://rdoc.info/projects/plataformatec/devise
57
53
 
54
+ If you want to use Devise with bundler on Rails 2.3, you need to follow the instructions here:
55
+
56
+ http://github.com/carlhuda/bundler/issues/issue/83
57
+
58
58
  == Basic Usage
59
59
 
60
60
  This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration. You MUST also check out the *Generators* section below to help you start.
data/Rakefile CHANGED
@@ -44,7 +44,7 @@ begin
44
44
  s.description = "Flexible authentication solution for Rails with Warden"
45
45
  s.authors = ['José Valim', 'Carlos Antônio']
46
46
  s.files = FileList["[A-Z]*", "{app,config,generators,lib}/**/*", "init.rb"]
47
- s.add_dependency("warden", "~> 0.9.0")
47
+ s.add_dependency("warden", "~> 0.9.3")
48
48
  end
49
49
 
50
50
  Jeweler::GemcutterTasks.new
@@ -27,7 +27,7 @@ class DeviseMailer < ::ActionMailer::Base
27
27
  from mailer_sender(mapping)
28
28
  recipients record.email
29
29
  sent_on Time.now
30
- content_type 'text/html'
30
+ content_type Devise.mailer_content_type
31
31
  body render_with_scope(key, mapping, mapping.name => record, :resource => record)
32
32
  end
33
33
 
@@ -3,6 +3,9 @@
3
3
  Devise.setup do |config|
4
4
  # Configure the e-mail address which will be shown in DeviseMailer.
5
5
  config.mailer_sender = "please-change-me@config-initializers-devise.com"
6
+
7
+ # Configure the content type of DeviseMailer mails (defaults to text/html")
8
+ # config.mailer_content_type = "text/plain"
6
9
 
7
10
  # ==> Configuration for :authenticatable
8
11
  # Invoke `rake secret` and use the printed value to setup a pepper to generate
@@ -1,5 +1,6 @@
1
1
  module Devise
2
2
  autoload :FailureApp, 'devise/failure_app'
3
+ autoload :Models, 'devise/models'
3
4
  autoload :Schema, 'devise/schema'
4
5
  autoload :TestHelpers, 'devise/test_helpers'
5
6
 
@@ -144,7 +145,11 @@ module Devise
144
145
 
145
146
  # Address which sends Devise e-mails.
146
147
  mattr_accessor :mailer_sender
147
- @@mailer_sender = nil
148
+ @@mailer_sender = nil
149
+
150
+ # Content Type of Devise e-mails.
151
+ mattr_accessor :mailer_content_type
152
+ @@mailer_content_type = 'text/html'
148
153
 
149
154
  # Authentication token params key name of choice. E.g. /users/sign_in?some_key=...
150
155
  mattr_accessor :token_authentication_key
@@ -3,7 +3,7 @@
3
3
  # that specific user and adds a cookie with this user info to sign in this user
4
4
  # automatically without asking for credentials. Refer to rememberable strategy
5
5
  # for more info.
6
- Warden::Manager.after_authentication do |record, warden, options|
6
+ Warden::Manager.prepend_after_authentication do |record, warden, options|
7
7
  scope = options[:scope]
8
8
  remember_me = warden.params[scope].try(:fetch, :remember_me, nil)
9
9
 
@@ -38,7 +38,7 @@ module Devise
38
38
 
39
39
  def custom_headers
40
40
  {
41
- "Content-Type" => "text/plain",
41
+ "Content-Type" => Mime::Type.lookup_by_extension(request.template_format.to_s).to_s,
42
42
  "WWW-Authenticate" => %(Basic realm="#{Devise.http_authentication_realm.gsub(/"/, "")}")
43
43
  }
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
@@ -16,6 +16,12 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
16
16
  assert_equal 'Basic realm="Application"', headers["WWW-Authenticate"]
17
17
  end
18
18
 
19
+ test 'uses the request format as response content type' do
20
+ sign_in_as_new_user_with_http("unknown", "123456", :xml)
21
+ assert_equal 401, status
22
+ assert_equal "application/xml", headers["Content-Type"]
23
+ end
24
+
19
25
  test 'returns a custom response with www-authenticate and chosen realm' do
20
26
  swap Devise, :http_authentication_realm => "MyApp" do
21
27
  sign_in_as_new_user_with_http("unknown")
@@ -36,9 +42,9 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
36
42
 
37
43
  private
38
44
 
39
- def sign_in_as_new_user_with_http(username="user@test.com", password="123456")
45
+ def sign_in_as_new_user_with_http(username="user@test.com", password="123456", format=:html)
40
46
  user = create_user
41
- get users_path, {}, :authorization => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
47
+ get users_path(:format => format), {}, :authorization => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
42
48
  user
43
49
  end
44
50
  end
@@ -63,6 +63,12 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
63
63
  end
64
64
  end
65
65
 
66
+ test 'content type should be set to plain when manually configured' do
67
+ swap Devise, :mailer_content_type => "text/plain" do
68
+ assert_equal "text/plain", mail.content_type
69
+ end
70
+ end
71
+
66
72
  test 'renders a scoped if scoped_views is set in the mailer class' do
67
73
  begin
68
74
  DeviseMailer.scoped_views = true
@@ -35,6 +35,9 @@ Devise.setup do |config|
35
35
 
36
36
  # Configure the e-mail address which will be shown in DeviseMailer.
37
37
  config.mailer_sender = "please-change-me-omg@yourapp.com"
38
+
39
+ # Configure the content type of DeviseMailer mails (defaults to text/html")
40
+ # config.mailer_content_type = "text/plain"
38
41
 
39
42
  # Load and configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
40
43
  require "devise/orm/#{DEVISE_ORM}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
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
  - "Jos\xC3\xA9 Valim"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-17 00:00:00 +01:00
13
+ date: 2010-02-18 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: 0.9.0
24
+ version: 0.9.3
25
25
  version:
26
26
  description: Flexible authentication solution for Rails with Warden
27
27
  email: contact@plataformatec.com.br