Merge pull request #1448 from mz3944/mz-SCI-2929

Can not switch team [SCI-2929]
This commit is contained in:
mz3944 2019-01-31 04:43:39 +01:00 committed by GitHub
commit 2ae56eb13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,8 +75,10 @@ class ApplicationController < ActionController::Base
private
def update_current_team
if current_user.current_team_id.blank? &&
current_user.teams.count > 0
current_team = Team.find_by_id(current_user.current_team_id)
if (current_team.nil? || !current_user.is_member_of_team?(current_team)) &&
current_user.teams.count.positive?
current_user.update(
current_team_id: current_user.teams.first.id
)