can be simplified:

```ruby
options = { :name => auth_source_name }
auth_source = AuthSourceExternal.where(options).first || AuthSourceExternal.create!(options)
User.create!(:login => login, :auth_source => auth_source)
```

this first ensures we are always talking about External Authsources vs any authsource.

secondly, I'm wondering what happens if AutoSource is created, but user does not, I did not try, but we could try using the build method instead and save them in one go... maybe something like

```ruby
options = { :name => auth_source_name }
auth_source = AuthSourceExternal.where(options).first || AuthSourceExternal.build(options)
User.create!(:login => login, :auth_source => auth_source)
```
AFAIK (require a bit testing) would create both user and auth source in the same transaction. (would nice to see a test like that).