Class: Vines::Stanza::Iq::Register

Inherits:
Query show all
Defined in:
lib/vines/stanza/iq/register.rb

Constant Summary collapse

NS =
NAMESPACES[:register]

Constants inherited from Vines::Stanza::Iq

VALID_TYPES

Constants inherited from Vines::Stanza

EMPTY, ROUTABLE_STANZAS

Instance Attribute Summary

Attributes inherited from Vines::Stanza

#stream

Instance Method Summary collapse

Methods inherited from Vines::Stanza::Iq

#to_result

Methods inherited from Vines::Stanza

#broadcast, from_node, #initialize, #local?, #local_jid?, #method_missing, register, #route, #router, #send_unavailable, #storage, #to_pubsub_domain?, #unavailable, #validate_from, #validate_to

Constructor Details

This class inherits a constructor from Vines::Stanza

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vines::Stanza

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vines/stanza/iq/register.rb', line 11

def process
  if is_stream_owner
    current_user = storage(stream.domain).find_user(stream.user.jid)
    password = @node.xpath("//iq/jir:query//jir:password", {"jir"=>"jabber:iq:register"}).text
    unless password.nil?
      current_user.password = BCrypt::Password.create(password.to_s)
      storage.save_user(current_user)
      stream.write(to_result)
    else
     raise StanzaErrors::NotAcceptable.new(self, 'cancel')
    end
  else

  end
end