mirror of
https://github.com/System-End/identity-vault.git
synced 2026-04-19 22:05:07 +00:00
fix deac?
This commit is contained in:
parent
abb3d8c14b
commit
34b447d4d0
2 changed files with 18 additions and 19 deletions
|
|
@ -129,21 +129,20 @@ class SAMLController < ApplicationController
|
|||
def try_assign_to_slack_workspace
|
||||
return unless current_identity.slack_id.present?
|
||||
|
||||
# Check if user is already in workspace
|
||||
if SlackService.user_in_workspace?(user_id: current_identity.slack_id)
|
||||
case SlackService.user_workspace_status(user_id: current_identity.slack_id)
|
||||
when :in_workspace
|
||||
current_identity.update(is_in_workspace: true) unless current_identity.is_in_workspace
|
||||
return
|
||||
when :not_in_workspace
|
||||
scenario = current_identity.onboarding_scenario_instance
|
||||
return unless scenario.slack_channels.any?
|
||||
|
||||
AssignSlackWorkspaceJob.perform_later(
|
||||
slack_id: current_identity.slack_id,
|
||||
user_type: :multi_channel_guest,
|
||||
channel_ids: scenario.slack_channels,
|
||||
identity_id: current_identity.id
|
||||
)
|
||||
end
|
||||
|
||||
scenario = current_identity.onboarding_scenario_instance
|
||||
return unless scenario.slack_channels.any?
|
||||
|
||||
AssignSlackWorkspaceJob.perform_later(
|
||||
slack_id: current_identity.slack_id,
|
||||
user_type: :multi_channel_guest,
|
||||
channel_ids: scenario.slack_channels,
|
||||
identity_id: current_identity.id
|
||||
)
|
||||
end
|
||||
|
||||
def check_enterprise_features!
|
||||
|
|
|
|||
|
|
@ -52,18 +52,18 @@ module SlackService
|
|||
false
|
||||
end
|
||||
|
||||
def user_in_workspace?(user_id:)
|
||||
def user_workspace_status(user_id:)
|
||||
response = client.users_info(user: user_id)
|
||||
user = response.dig("user")
|
||||
|
||||
return false unless user
|
||||
return false if user["deleted"]
|
||||
return :unknown unless user
|
||||
return :deactivated if user["deleted"]
|
||||
|
||||
teams = user["teams"] || []
|
||||
teams.include?(team_id)
|
||||
teams.include?(team_id) ? :in_workspace : :not_in_workspace
|
||||
rescue => e
|
||||
Rails.logger.warn "Could not check if user #{user_id} is in workspace: #{e.message}"
|
||||
false
|
||||
Rails.logger.warn "Could not check workspace status for user #{user_id}: #{e.message}"
|
||||
:unknown
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue