Skip to content

Latest commit

 

History

History
102 lines (73 loc) · 3.03 KB

3.0.md

File metadata and controls

102 lines (73 loc) · 3.03 KB
Checklist:

[ ] Set a global URL [ ] connected_state => connected? [ ] auth no longer calls cancel block [ ] unauth => logout [ ] auth_state => authenticated? [ ] on_auth => authenticated? [ ] FirebaseSimpleLogin is GONE

Added the ability to set a global URL

Firebase.url = 'your-app-name'

This is required if you want to use the static methods like Firebase.connected?

connected_state => connected?

connected_state is still around, but it has been improved and renamed to connected?, which accepts a block. Instead of a snapshot, this block will receive a boolean (is_connected).

Firebase.authenticate

This method used to call authWithCredential(withCompletionBlock:withCancelBlock:), but that method has been deprecated in favor of authWithCustomToken(withCompletionBlock:).

The new method uses just one block. You should update your code to accept error and auth_data arguments, and use Firebase.authenticated? to monitor authenticated state.

Firebase.authenticate(token) { |error, auth_data| }
Firebase.unauth

Is now Firebase.logout

Firebase.auth_state

Is gone, in favor of Firebase.authenticated?. You can no longer get a Firebase ref that points to the auth state directly.

Firebase.on_auth

Is gone, in favor of Firebase.authenticated?

FirebaseSimpleLogin is GONE

No more motion-firebase-auth at all. Porting is pretty easy, though.

Before, you had to get create a FirebaseSimpleLogin object

auth = FirebaseSimpleLogin.new(firebase_ref)
auth.login(email: email, password: password)
auth.logout

Now you just use the firebase_ref directly, and it's encouraged to use the static version of these methods.

Firebase.login(email: email, password: password)
Firebase.logout

Many of the methods like create, etc are appended with _user, and again the static version is encouraged.

# FirebaseSimpleLogin methods:
auth.create(email:, password:)
auth.remove(email:, password:) { |error| }
auth.login(email:, password:) { |error, user| }
auth.update(email:, old_password:, new_password:) { |error, success| }
auth.send_password_reset(email:)

# are now:
Firebase.create_user_and_login(email:, password:) { |error, auth_data| }
Firebase.create_user(email:, password:) { |error| }  # user is not logged in!
Firebase.remove_user(email:, password:) { |error| }
Firebase.login(email:, password:) { |error, auth_data| }
Firebase.update_user(email:, old_password:, new_password:) { |error| }
Firebase.send_password_reset(email:) { |error| }

# this one is new:
Firebase.login_anonymously { |error, auth_data| }

Removed methods:

auth.check { |error, user| }
Firebase.authenticated? { |is_authenticated| }  # does the same thing, pretty much

The Facebook and Twitter methods are different, you'll need to use open_facebook_session and open_twitter_session. The old methods (login_to_facebook) did a lot more, but at the sacrifice that you lost some control of your app. The new methods are more hands off.