mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-16 01:54:34 +08:00
Switch user's team if he's no longer a member of the currently selected one
This commit is contained in:
parent
b530cea771
commit
a5c1cf4450
1 changed files with 4 additions and 2 deletions
|
@ -65,8 +65,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
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue