motion-firebase 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +9 -1
- data/lib/firebase/firebase.rb +4 -0
- data/lib/firebase/version.rb +1 -1
- data/lib/firebase-auth/firebase_auth_client.rb +41 -24
- metadata +2 -2
data/README.md
CHANGED
@@ -105,6 +105,14 @@ SDK
|
|
105
105
|
disconnect: proc { |error| 'completion block', },
|
106
106
|
)
|
107
107
|
firebase.unauth
|
108
|
+
# when using FirebaseAuthClient to authenticate, this child node should be
|
109
|
+
# monitored for changes
|
110
|
+
firebase.auth_state
|
111
|
+
# usually you'll want to monitor its value, so this is a helper for that:
|
112
|
+
handle = firebase.on_auth do |snapshot|
|
113
|
+
end
|
114
|
+
# be a good citizen and turn off the listener later!
|
115
|
+
firebase.off(handle)
|
108
116
|
|
109
117
|
##### Transactions
|
110
118
|
|
@@ -166,7 +174,7 @@ For `update`, `credentials` should include `:email`, `:old_password` and
|
|
166
174
|
|
167
175
|
`credentials` should include `:app_id` and `:permissions`
|
168
176
|
|
169
|
-
auth.
|
177
|
+
auth.login_to_facebook(app_id: '123abc', permissions: ['email']) { |error, user| }
|
170
178
|
|
171
179
|
##### Twitter authentication methdos
|
172
180
|
|
data/lib/firebase/firebase.rb
CHANGED
data/lib/firebase/version.rb
CHANGED
@@ -9,57 +9,74 @@ class FirebaseAuthClient
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def create(credentials, &block)
|
12
|
+
raise "email is required in #{__method__}" unless credentials.key?(:email)
|
13
|
+
raise "password is required in #{__method__}" unless credentials.key?(:password)
|
12
14
|
email = credentials[:email]
|
13
|
-
raise "email is required in #{__method__}" unless email
|
14
15
|
password = credentials[:password]
|
15
|
-
|
16
|
-
|
16
|
+
begin
|
17
|
+
createUserWithEmail(email, password:password, andCompletionBlock:block)
|
18
|
+
rescue RuntimeError => e
|
19
|
+
block.call(e, nil)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def remove(credentials, &block)
|
24
|
+
raise "email is required in #{__method__}" unless credentials.key?(:email)
|
25
|
+
raise "password is required in #{__method__}" unless credentials.key?(:password)
|
20
26
|
email = credentials[:email]
|
21
|
-
raise "email is required in #{__method__}" unless email
|
22
27
|
password = credentials[:password]
|
23
|
-
raise "password is required in #{__method__}" unless password
|
24
28
|
removeUserWithEmail(email, password:password, andCompletionBlock:block)
|
25
29
|
end
|
26
30
|
|
27
31
|
def login(credentials, &block)
|
32
|
+
raise "email is required in #{__method__}" unless credentials.key?(:email)
|
33
|
+
raise "password is required in #{__method__}" unless credentials.key?(:password)
|
28
34
|
email = credentials[:email]
|
29
|
-
raise "email is required in #{__method__}" unless email
|
30
35
|
password = credentials[:password]
|
31
|
-
|
32
|
-
|
36
|
+
begin
|
37
|
+
loginWithEmail(email, andPassword:password, withCompletionBlock:block)
|
38
|
+
rescue RuntimeError => e
|
39
|
+
block.call(e, nil)
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
def update(credentials, &block)
|
44
|
+
raise "email is required in #{__method__}" unless credentials.key?(:email)
|
45
|
+
raise "old_password is required in #{__method__}" unless credentials.key?(:old_password)
|
46
|
+
raise "new_password is required in #{__method__}" unless credentials.key?(:new_password)
|
36
47
|
email = credentials[:email]
|
37
|
-
raise "email is required in #{__method__}" unless email
|
38
48
|
old_password = credentials[:old_password]
|
39
|
-
raise "old_password is required in #{__method__}" unless old_password
|
40
49
|
new_password = credentials[:new_password]
|
41
|
-
raise "new_password is required in #{__method__}" unless new_password
|
42
50
|
changePasswordForEmail(email, oldPassword:old_password, newPassword:new_password, completionBlock:block)
|
43
51
|
end
|
44
52
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
def login_to_facebook(credentials, &block)
|
54
|
+
if credentials.is_a?(NSString)
|
55
|
+
app_id = credentials
|
56
|
+
credentials = {}
|
57
|
+
else
|
58
|
+
app_id = credentials[:app_id]
|
59
|
+
raise "app_id is required in #{__method__}" unless app_id
|
60
|
+
end
|
61
|
+
permissions = credentials[:permissions] || ['email']
|
62
|
+
audience = credentials[:audience] || ACFacebookAudienceOnlyMe
|
63
|
+
loginToFacebookAppWithId(app_id, permissions:permissions, audience:audience, withCompletionBlock:block)
|
51
64
|
end
|
52
65
|
|
53
66
|
def login_to_twitter(credentials, &block)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
67
|
+
if credentials.is_a?(String)
|
68
|
+
app_id = credentials
|
69
|
+
credentials = {}
|
70
|
+
else
|
71
|
+
app_id = credentials[:app_id]
|
72
|
+
raise "app_id is required in #{__method__}" unless app_id
|
73
|
+
end
|
74
|
+
on_multiple = credentials[:on_multiple] || ->(accounts) { accounts[0] }
|
58
75
|
loginToTwitterAppWithId(app_id, multipleAccountsHandler:on_multiple, withCompletionBlock:block)
|
59
76
|
end
|
60
77
|
|
61
|
-
def inspect
|
62
|
-
|
63
|
-
end
|
78
|
+
# def inspect
|
79
|
+
# "#<#{self.class}:0x#{self.object_id.to_s(16)}>"
|
80
|
+
# end
|
64
81
|
|
65
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-firebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|