require 'omniauth-oauth2'
require 'multi_json'

class OmniAuth::Strategies::Gds < OmniAuth::Strategies::OAuth2
  uid { user['uid'] }

  info do
    {
      name: user['name'],
      email: user['email']
    }
  end

  extra do
    {
      user: user,
      permissions: user['permissions'],
      organisation_slug: user['organisation_slug'],
    }
  end

  def user
    @user ||= MultiJson.decode(access_token.get('/user.json').body)['user']
  end

end

require 'omniauth-oauth2'
require 'multi_json'

class OmniAuth::Strategies::Gds < OmniAuth::Strategies::OAuth2
  uid { user['uid'] }

  info do
    {
      name: user['name'],
      email: user['email']
    }
  end

  extra do
    {
      user: user,
      permissions: user['permissions'],
      organisation_slug: user['organisation_slug'],
    }
  end

  def user
    @user ||= MultiJson.decode(access_token.get("/user.json?client_id=#{CGI.escape(options.client_id)}").body)['user']
  end

end

Include client_id when requesting user details.
Include client_id when requesting user details.

To fix a token transfer issue.  See
https://github.com/alphagov/signonotron2/pull/245 for more details.
