Class: OmniAuth::Strategies::ExpressoV3

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/expressov3.rb

Constant Summary collapse

@@config =
{
 :account_id => 'currentAccount::accountId',
 :contact_id =>  'userContact::id',
 :username => 'currentAccount::accountLoginName',
 :name => 'currentAccount::accountFullName',
 :first_name => 'currentAccount::accountFirstName',
 :last_name => 'currentAccount::accountLastName',
 :email => 'currentAccount::accountEmailAddress',
 :telephone => 'userContact::tel_work',
 :organization_unit => 'userContact::org_unit',
 :tine_key => 'keys::tine_key',
 :json_key => 'keys::json_key',
 :cookies => 'keys::cookies'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.map_user(mapper, object) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/omniauth/strategies/expressov3.rb', line 79

def self.map_user(mapper, object)
  user = {}
  mapper.each do |key, value|
    values_keys = value.split('::')
    value_key = values_keys[0].to_sym
    sub_value_key = values_keys[1].to_sym
    if object && object.respond_to?(value_key) && object.send(value_key) && object.send(value_key).respond_to?(sub_value_key)
      user[key] = object.send(value_key).send(sub_value_key)
    else
      user[key] = nil
    end
  end
  user
end

Instance Method Details

#callback_phaseObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/omniauth/strategies/expressov3.rb', line 46

def callback_phase
  @auth_client = OmniAuth::ExpressoV3::AuthClient.new @options

  return fail!(:missing_credentials) if missing_credentials?
  begin
    @auth_info = @auth_client.authenticate(request['username'], request['password'])

    return fail!(:invalid_credentials) if !@auth_info

    @expresso_user_info = @auth_client.get_user_data

    @user_info = map_user_data(@expresso_user_info)

    super
  rescue Exception => e
    return fail!(:expressov3_error, e)
  end
end

#map_user_data(expresso_user_info) ⇒ Object



65
66
67
# File 'lib/omniauth/strategies/expressov3.rb', line 65

def map_user_data()
  self.class.map_user(@@config, )
end

#request_phaseObject

option :on_login, nil option :on_registration, nil option :on_failed_registration, nil option :locate_conditions, lambda{|req| {model.auth_key => req} }



37
38
39
40
41
42
43
44
# File 'lib/omniauth/strategies/expressov3.rb', line 37

def request_phase
  #OmniAuth::Expressov3::AuthClient.validate @options
  f = OmniAuth::Form.new(:title => (options[:title] || "AutenticaĆ§Ć£o Expresso "), :url => callback_path)
  f.text_field 'Login', 'username'
  f.password_field 'Password', 'password'
  f.button "Sign In"
  f.to_response
end