Class: Parse::User

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/user.rb

Instance Attribute Summary

Attributes inherited from Object

#class_name, #created_at, #parse_object_id, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#array_add, #array_add_relation, #array_add_unique, #array_remove, #as_json, #decrement, #eql?, #get, #hash, #increment, #inspect, #new?, #parse_delete, #pointer, #refresh, #safe_hash, #safe_json, #save, #to_json, #to_s

Constructor Details

#initialize(data = nil) ⇒ User

Returns a new instance of User.



26
27
28
29
30
# File 'lib/parse/user.rb', line 26

def initialize(data = nil)
  data["username"] = data[:username] if data[:username]
  data["password"] = data[:password] if data[:password]
  super(Parse::Protocol::CLASS_USER, data)
end

Class Method Details

.authenticate(username, password) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/parse/user.rb', line 9

def self.authenticate(username, password)
  body = {
    "username" => username,
    "password" => password
  }

  response = Parse.client.request(Parse::Protocol::USER_LOGIN_URI, :get, nil, body)
  Parse.client.session_token = response[Parse::Protocol::KEY_USER_SESSION_TOKEN]

  new(response)
end

.reset_password(email) ⇒ Object



21
22
23
24
# File 'lib/parse/user.rb', line 21

def self.reset_password(email)
  body = {"email" => email}
  Parse.client.post(Parse::Protocol::PASSWORD_RESET_URI, body.to_json)
end

Instance Method Details

#uriObject



32
33
34
# File 'lib/parse/user.rb', line 32

def uri
  Protocol.user_uri @parse_object_id
end