diff --git a/app/controllers/devise/sessions_controller.rb b/app/controllers/devise/sessions_controller.rb index 95b12cdd..73c77110 100644 --- a/app/controllers/devise/sessions_controller.rb +++ b/app/controllers/devise/sessions_controller.rb @@ -4,8 +4,9 @@ class Devise::SessionsController < ApplicationController # GET /resource/sign_in def new - clean_up_passwords(build_resource) - render_with_scope :new + resource = build_resource + clean_up_passwords(resource) + respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new } end # POST /resource/sign_in @@ -33,4 +34,12 @@ class Devise::SessionsController < ApplicationController end end end -end + + protected + + def stub_options(resource) + hash = { :only => resource_class.authentication_keys } + hash[:methods] = [:password] if resource.respond_to?(:password) + hash + end +end \ No newline at end of file diff --git a/lib/devise/models/database_authenticatable.rb b/lib/devise/models/database_authenticatable.rb index 90003c1b..ad1fdbb2 100644 --- a/lib/devise/models/database_authenticatable.rb +++ b/lib/devise/models/database_authenticatable.rb @@ -41,7 +41,7 @@ module Devise # Set password and password confirmation to nil def clean_up_passwords - self.password = self.password_confirmation = nil + self.password = self.password_confirmation = "" end # Update record attributes when :current_password matches, otherwise returns diff --git a/test/integration/authenticatable_test.rb b/test/integration/authenticatable_test.rb index 12c6a774..5bfee59e 100644 --- a/test/integration/authenticatable_test.rb +++ b/test/integration/authenticatable_test.rb @@ -336,10 +336,14 @@ class AuthenticationOthersTest < ActionController::IntegrationTest end end - test 'registration in xml format works when recognizing path' do - assert_nothing_raised do - post user_registration_path(:format => 'xml', :user => {:email => "test@example.com", :password => "invalid"} ) - end + test 'sign in stub in xml format' do + get new_user_session_path(:format => 'xml') + assert_equal "\n\n \n \n\n", response.body + end + + test 'sign in stub in json format' do + get new_user_session_path(:format => 'json') + assert_equal "{\"user\":{\"password\":\"\",\"email\":\"\"}}", response.body end test 'uses the mapping from router' do