Developing sessions for multiple users

I am creating an application with two fairly separate models using devus for auth. As soon as you enter the house, everyone in the house can enter as a resident of this house. Everything works fine, except when I exit a resident session using

destroy_resident_session 

The only problem is that it also kills the home session, as it causes

 Devise::SessionsController#destroy 

I tried to create a user session for residents, here is my code below:

 class SessionsController < Devise::SessionsController # DELETE /resource/sign_out def destroy redirect_path = after_sign_out_path_for(resource_name) signed_out = sign_out(resident) set_flash_message :notice, :signed_out if signed_out && is_navigational_format? # We actually need to hardcode this as Rails default responder doesn't # support returning empty response on GET request respond_to do |format| format.all { head :no_content } format.any(*navigational_formats) { redirect_to redirect_path } end end end 

This gives an error:

 undefined local variable or method `resident' 

Maybe I'm wrong in the logic of the method, but it seems to me that I want to change the following line in the development controller:

 signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)) 

Since I do not want to leave all areas, this is only a field of residency.

solvable

All I had to do was install

  config.sign_out_all_scopes = false 

in

 config/devise.rb 

Also, do not forget to restart my server :)

+4
source share
1 answer

This should be noted as an answer. You did not publish it, but I had the same problem and it was a solution, so I am posting it to the community

config / devise.rb

  config.sign_out_all_scopes = false 
+2
source

Source: https://habr.com/ru/post/1489819/


All Articles