I have two devise authentication models in my app and want to create a chat amongst them. Can someone help me write the connection for the users? Below is what I have. I wanted to check if I can have two connections reject the connections for different users based on their individual logins. Any help is appreciated.
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
identified_by :current_supplier
def connect
self.current_user = find_verified_user
self.current_supplier = find_verified_supplier
end
private
def find_verified_user
if current_user = env['warden'].user('user')
current_user
end
end
def find_verified_supplier
if current_supplier = env['warden'].user('supplier')
current_supplier
else
reject_unauthorized_connection
end
end
end
end