dm-parse 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dm-parse.gemspec +1 -1
- data/lib/is/parse.rb +14 -0
- data/spec/integration_spec.rb +6 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/dm-parse.gemspec
CHANGED
data/lib/is/parse.rb
CHANGED
@@ -18,9 +18,23 @@ module DataMapper
|
|
18
18
|
property :email, Property::String, format: :email_address
|
19
19
|
|
20
20
|
class << self
|
21
|
+
# Authenticate a user
|
22
|
+
#
|
23
|
+
# @param [String] username
|
24
|
+
# username
|
25
|
+
#
|
26
|
+
# @param [String] password
|
27
|
+
# password
|
28
|
+
#
|
29
|
+
# @return [Resource, nil]
|
30
|
+
# the user resource, or nil if authentication failed
|
31
|
+
#
|
32
|
+
# @api semipublic
|
21
33
|
def authenticate(username, password)
|
22
34
|
result = repository.adapter.sign_in(username, password)
|
23
35
|
get(result["objectId"])
|
36
|
+
rescue ::Parse::ParseError
|
37
|
+
nil
|
24
38
|
end
|
25
39
|
|
26
40
|
def request_password_reset(email)
|
data/spec/integration_spec.rb
CHANGED
@@ -135,6 +135,12 @@ describe User do
|
|
135
135
|
subject { model.authenticate username, password }
|
136
136
|
|
137
137
|
it { should eq(user) }
|
138
|
+
|
139
|
+
context "when adapter raise error" do
|
140
|
+
before { DataMapper::Adapters::ParseAdapter.any_instance.stub(:sign_in).and_raise(Parse::ParseError) }
|
141
|
+
|
142
|
+
it { should be_nil }
|
143
|
+
end
|
138
144
|
end
|
139
145
|
end
|
140
146
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-parse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -242,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: '0'
|
243
243
|
segments:
|
244
244
|
- 0
|
245
|
-
hash:
|
245
|
+
hash: 4240417428092590610
|
246
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
247
|
none: false
|
248
248
|
requirements:
|