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 394f867..766ab37 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 37b8a7f..6a2769f 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