Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ParseUser superclass for User objects

usage:
class User < ParseUser; end
u1 = User.create(:username => "Alan", :password => "foo")
u2 = User.login(:username => "Alan", :password => "foo")
u1.id == u2.id #=> true
  • Loading branch information...
commit 72c6b26053cdd9e5bba295a2ded63d5d6c1d692c 1 parent 6d7fdb8
@adelevie authored
Showing with 16 additions and 0 deletions.
  1. +1 −0  lib/parse_resource.rb
  2. +15 −0 lib/parse_user.rb
View
1  lib/parse_resource.rb
@@ -1,5 +1,6 @@
require 'base'
require 'query'
+require 'parse_user'
module ParseResource
end
View
15 lib/parse_user.rb
@@ -0,0 +1,15 @@
+class ParseUser < ParseResource::Base
+ fields :username, :password
+
+ def self.login(username, password)
+ base_uri = "https://api.parse.com/1/login"
+ app_id = settings['app_id']
+ master_key = settings['master_key']
+ resource = RestClient::Resource.new(base_uri, app_id, master_key)
+
+ resp = resource.get(:params => {:username => username, :password => password})
+ user = model_name.constantize.new(JSON.parse(resp), false)
+
+ user
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.