omniauth-campus 8.3 → 8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/omniauth-campus/version.rb +1 -1
- data/lib/omniauth/strategies/campus.rb +21 -34
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b83c42f59a52b501d1d913a2adcf5dab376cb637
         | 
| 4 | 
            +
              data.tar.gz: 4adbc562e1a6230f79a3792d06bd4dc3b5fe06b2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a52c92f2e090c7a7b1d5f12b4de6fd19739158d418e2cc51fc596e6243baa9bdd383dc43c7be42e8b7cad1e128e28acec7cd4423fb266a0797e47d1b5118628b
         | 
| 7 | 
            +
              data.tar.gz: e91525672723467e132d969b9726fe93751515c0644ba8f8fb38369fd593545b2d64ff255ca76b1089cf4a3b745407063aa4b61c0fc9baa58a9030a796e92625
         | 
| @@ -1,43 +1,30 @@ | |
| 1 | 
            -
            require 'omniauth'
         | 
| 2 | 
            -
            require ' | 
| 1 | 
            +
            require 'omniauth-oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 3 |  | 
| 4 4 | 
             
            module OmniAuth
         | 
| 5 5 | 
             
              module Strategies
         | 
| 6 | 
            -
                class Campus 
         | 
| 7 | 
            -
                   | 
| 8 | 
            -
             | 
| 9 | 
            -
                  option :user_model, nil # default set to 'User' below
         | 
| 10 | 
            -
                  option :login_field, :email
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  def request_phase
         | 
| 13 | 
            -
                    redirect "/session/new"
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                  def callback_phase
         | 
| 17 | 
            -
                    return fail!(:invalid_credentials) unless user.try(:authenticate, password)
         | 
| 18 | 
            -
                    super
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  def user
         | 
| 22 | 
            -
                    @user ||= user_model.send("find_by_#{options[:login_field]}", login)
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                  def user_model
         | 
| 26 | 
            -
                    options[:user_model] || ::User
         | 
| 27 | 
            -
                  end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                  def login
         | 
| 30 | 
            -
                    request[:sessions][options[:login_field].to_s]
         | 
| 31 | 
            -
                  end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  def password
         | 
| 34 | 
            -
                    request[:sessions]['password']
         | 
| 35 | 
            -
                  end
         | 
| 6 | 
            +
                class Campus < OmniAuth::Strategies::OAuth
         | 
| 7 | 
            +
                  option :name, :campus
         | 
| 36 8 |  | 
| 9 | 
            +
                  option :client_options, {
         | 
| 10 | 
            +
                      :site => "http://community3dev.devcloud.acquia-sites.com/api"
         | 
| 11 | 
            +
                  }   
         | 
| 12 | 
            +
                     
         | 
| 37 13 | 
             
                  uid do
         | 
| 38 | 
            -
                     | 
| 14 | 
            +
                    raw_info[0]['uid']
         | 
| 15 | 
            +
                  end    
         | 
| 16 | 
            +
                  
         | 
| 17 | 
            +
                  info do
         | 
| 18 | 
            +
                    {
         | 
| 19 | 
            +
                        :name => raw_info[0]['users_name'],
         | 
| 20 | 
            +
                        :email => raw_info[0]['users_mail']
         | 
| 21 | 
            +
                    } 
         | 
| 39 22 | 
             
                  end
         | 
| 40 23 |  | 
| 41 | 
            -
             | 
| 24 | 
            +
                  def raw_info 
         | 
| 25 | 
            +
                    @raw_info ||= MultiJson.decode(access_token.get("http://community3dev.devcloud.acquia-sites.com/api").body)
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
              end
         | 
| 42 28 | 
             
              end
         | 
| 43 29 | 
             
            end
         | 
| 30 | 
            +
             |