Class: WeConnect::Authentication::PasswordFormParser

Inherits:
Object
  • Object
show all
Defined in:
lib/weconnect/authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ PasswordFormParser

Returns a new instance of PasswordFormParser.



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/weconnect/authorization.rb', line 185

def initialize(html)
  doc = Nokogiri::HTML( html )
  # 1 loginform username
  form = doc/'form[name="emailPasswordForm"]'
  if form
    @action = form.attribute('action').to_s
    @method = form.attribute('method').to_s
    # get hidden fields

    @fields = {}
    (form/'input').each do |input|
      @fields[input.attribute('name').to_s] = input.attribute('value').to_s
    end
  else
    raise IncompatibleAPIError.new( 'emailPasswordForm not found' )
  end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



184
185
186
# File 'lib/weconnect/authorization.rb', line 184

def action
  @action
end

#fieldsObject (readonly)

Returns the value of attribute fields.



184
185
186
# File 'lib/weconnect/authorization.rb', line 184

def fields
  @fields
end

#methodObject (readonly)

Returns the value of attribute method.



184
185
186
# File 'lib/weconnect/authorization.rb', line 184

def method
  @method
end