Does this add groups one by one? Wouldn't it be better to do something like
```ruby
if external_groups.present?
  existing = user.usergroups
  user.usergroups = (existing + ExternalUsergroup.where(:auth_source_id => auth_source, :name => external_groups).map(&:usergroup)).uniq
end
```

maye unfold the logic a bit so it's more readable, but you get the idea