Treeat user as logged in after a password reset
authorTom Hughes <tom@compton.nu>
Fri, 26 Feb 2016 16:30:32 +0000 (16:30 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 26 Feb 2016 16:30:32 +0000 (16:30 +0000)
Fixes #1160

app/controllers/user_controller.rb
test/controllers/user_controller_test.rb

index 394f8676f26987e3978fc2b0ecf99d2012332f95..766ab37d1396e437c4826b8d02b78b8e923c9fe8 100644 (file)
@@ -182,7 +182,7 @@ class UserController < ApplicationController
           if @user.save
             token.destroy
             flash[:notice] = t "user.reset_password.flash changed"
-            redirect_to :action => "login"
+            successful_login(@user)
           end
         end
       else
index 37b8a7f30efaf39987a87b2e4b5957e59ae6fa67..6a2769f17b2bbb329e08bf31170456fd8892fbd2 100644 (file)
@@ -702,7 +702,8 @@ class UserControllerTest < ActionController::TestCase
     # Test setting a new password
     post :reset_password, :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" }
     assert_response :redirect
-    assert_redirected_to :action => :login
+    assert_redirected_to root_path
+    assert_equal users(:inactive_user).id, session[:user]
     user = User.find(users(:inactive_user).id)
     assert_equal "active", user.status
     assert_equal true, user.email_valid