class OmniAuth::Strategies::Uoc

Public Class Methods

new(app, options = {}, &block) click to toggle source
Calls superclass method
# File lib/omniauth/strategies/uoc.rb, line 10
def initialize(app, options = {}, &block)
  options.symbolize_keys!()
  super(app, {:name=> :uoc}.merge(options), &block)
  @configuration = OmniAuth::Strategies::Uoc::Configuration.new(options)
end

Protected Instance Methods

auth_hash() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/uoc.rb, line 45
def auth_hash
  OmniAuth::Utils.deep_merge(super, {
      'uid' => @user_info[:extra][:id],
      'info' => @user_info
  })
end
callback_phase() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/uoc.rb, line 34
def callback_phase
  creds = session.delete 'omniauth.uoc'
  return fail!(:no_credentials) unless creds
  validator = UocValidator.new(@configuration, creds['username'], creds['password'])
  @user_info = validator.user_info

  return fail!(:invalid_credentials) if @user_info.nil? || @user_info.empty?

  super
end
get_credentials() click to toggle source
# File lib/omniauth/strategies/uoc.rb, line 27
def get_credentials
  OmniAuth::Form.build(:title => (options[:title] || 'UOC Authentication')) do
    text_field 'Login', 'username'
    password_field 'Password', 'password'
  end.to_response
end
request_phase() click to toggle source
# File lib/omniauth/strategies/uoc.rb, line 18
def request_phase
  if env['REQUEST_METHOD'] == 'GET'
    get_credentials
  else
    session['omniauth.uoc'] = {'username' => request['username'], 'password' => request['password']}
    redirect callback_url
  end
end