Shopify/omniauth-shopify-oauth2 — pull request #11 by christhomson (2014-03-05 22:05:59+00:00)
Title: Take advantage of OmniAuth's auth failure handling

@garymardell @odorcicd for review.

This resolves issue #10.

Before this change, it was really tough to handle the `invalid_site` error that occurs in the setup phase when an invalid shop URL is passed in.

Now, we call OmniAuth's `fail!` [method](https://github.com/intridea/omniauth/blob/c2a22c92a15378eaf2124282cfc3b71dc70edbd4/lib/omniauth/strategy.rb#L464-L475), which allows people to set their own behaviour for when an authentication error occurs. By default, this will redirect to `/auth/failure` in non-development environments.

Unfortunately, OmniAuth does not provide us with a way to achieve this from within the `setup_phase`, so it's done within the `request_phase` instead. The request_phase ([pretty much](https://github.com/intridea/omniauth/blob/c2a22c92a15378eaf2124282cfc3b71dc70edbd4/lib/omniauth/strategy.rb#L197-L217)) immediately follows the setup phase.