Users can log in on their phones again.
Something in devise broke for the :mobile format. More investigation needed; we're having this same issue on log out and incorrect password on mobile (though those pages are at least still usable).
This commit is contained in:
parent
c8e9225dfb
commit
fbf486dae6
2 changed files with 26 additions and 5 deletions
|
|
@ -5,6 +5,17 @@
|
|||
class SessionsController < Devise::SessionsController
|
||||
|
||||
after_filter :enqueue_update, :only => :create
|
||||
|
||||
def create
|
||||
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
sign_in(resource_name, resource)
|
||||
redirect_loc = redirect_location(resource_name, resource)
|
||||
respond_with resource, :location => redirect_loc do |format|
|
||||
format.mobile { redirect_to root_path }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def enqueue_update
|
||||
if current_user
|
||||
|
|
@ -13,5 +24,4 @@ class SessionsController < Devise::SessionsController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,14 +20,25 @@ describe SessionsController do
|
|||
@user = alice
|
||||
@user.password = "evankorth"
|
||||
@user.password_confirmation = "evankorth"
|
||||
@service = Services::Facebook.new(:access_token => "yeah")
|
||||
@user.services << @service
|
||||
@user.save
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "redirects to / for a normal user" do
|
||||
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
|
||||
response.should redirect_to root_path
|
||||
end
|
||||
it "redirects to / for a mobile user" do
|
||||
@request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'
|
||||
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
|
||||
response.should redirect_to root_path
|
||||
end
|
||||
it 'queues up an update job' do
|
||||
Resque.should_receive(:enqueue).with(Job::UpdateServiceUsers, @service.id)
|
||||
service = Services::Facebook.new(:access_token => "yeah")
|
||||
@user.services << service
|
||||
@user.save
|
||||
|
||||
Resque.should_receive(:enqueue).with(Job::UpdateServiceUsers, service.id)
|
||||
post :create, {"user"=>{"remember_me"=>"0", "username"=> @user.username,
|
||||
"password"=>"evankorth"}}
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue