Apply changes from team members in own editor
This commit is contained in:

committed by
Sebastian Serth

parent
69ba7270dd
commit
89afb599e4
@@ -2,10 +2,12 @@
|
||||
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
identified_by :current_user
|
||||
identified_by :current_user, :current_contributor
|
||||
|
||||
def connect
|
||||
# The order is important here, because a valid user is required to find a valid contributor.
|
||||
self.current_user = find_verified_user
|
||||
self.current_contributor = find_verified_contributor
|
||||
end
|
||||
|
||||
def disconnect
|
||||
@@ -24,5 +26,14 @@ module ApplicationCable
|
||||
current_user = ExternalUser.find_by(id: session[:external_user_id]) || InternalUser.find_by(id: session[:user_id])
|
||||
current_user || reject_unauthorized_connection
|
||||
end
|
||||
|
||||
def find_verified_contributor
|
||||
# Finding the current_contributor is similar to the code used in application_controller.rb#current_contributor
|
||||
if session[:pg_id]
|
||||
current_user.programming_groups.find(session[:pg_id])
|
||||
else
|
||||
current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user