Class: Parse::User
Overview
A Parse User parseplatform.github.io/docs/rest/guide/#users
Instance Attribute Summary
Attributes inherited from Object
#class_name, #client, #created_at, #parse_object_id, #updated_at
Class Method Summary collapse
- .authenticate(username, password, client = nil) ⇒ Object
- .reset_password(email, client = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(data = nil, client = nil) ⇒ User
constructor
A new instance of User.
- #uri ⇒ Object
Methods inherited from Object
#array_add, #array_add_relation, #array_add_unique, #array_remove, #array_remove_relation, #decrement, #eql?, #get, #hash, #increment, #inspect, #new?, #parse_delete, #pointer, #refresh, #rest_api_hash, #safe_hash, #save, #should_call_to_h?, #to_h, #to_json, #to_s, #update_attributes
Constructor Details
#initialize(data = nil, client = nil) ⇒ User
Returns a new instance of User.
31 32 33 34 35 36 |
# File 'lib/parse/user.rb', line 31 def initialize(data = nil, client = nil) client ||= Parse.client data['username'] = data[:username] if data[:username] data['password'] = data[:password] if data[:password] super(Parse::Protocol::CLASS_USER, data, client) end |
Class Method Details
.authenticate(username, password, client = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/parse/user.rb', line 11 def self.authenticate(username, password, client = nil) body = { 'username' => username, 'password' => password } client ||= Parse.client response = client.request( Parse::Protocol::USER_LOGIN_URI, :get, nil, body) client.session_token = response[Parse::Protocol::KEY_USER_SESSION_TOKEN] new(response, client) end |
.reset_password(email, client = nil) ⇒ Object
25 26 27 28 29 |
# File 'lib/parse/user.rb', line 25 def self.reset_password(email, client = nil) client ||= Parse.client body = { 'email' => email } client.post(Parse::Protocol::PASSWORD_RESET_URI, body.to_json) end |