Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

added support for authWithCustomToken #130

Closed

Conversation

carnevalle
Copy link

Added support for custom authentication https://www.firebase.com/docs/web/guide/login/custom.html

Usage

var Todo = Backbone.Firebase.Model.extend({...});
var Todos = Backbone.Firebase.Collection.extend({...});

var model = new Todo({}, {
    auth_token: AUTH_TOKEN
});
var collection = new Todos([], {
    auth_token: AUTH_TOKEN
});

collection.on('firebase:login:success', function(authData){
   // handle success
});
collection.on('firebase:login:error', function(error){
      // handle error
});

AUTH_TOKEN being a generated JWT

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.0%) when pulling 5d1529d on carnevalle:0.5.1-release into da5516b on firebase:0.5.1-release.

@davideast
Copy link
Contributor

I appreciate the PR.

However, we're not ready to add authentication to BackboneFire. A larger discussion needs to be had before we start implementing methods.

Once we're ready I'll post the CFPs on Github.

@davideast davideast closed this Jan 10, 2015
@carnevalle
Copy link
Author

You are not ready? How would you implement a real world app without authentication?

This is implemented as an option. You can turn on authentication if needed or leave it be if you don't need it. What are the complications?

@davideast
Copy link
Contributor

There are a few of complications.

You did not write any tests for the code you submitted. When adding new features we require tests.

If authentication is introduced in the library, it will be done with a thought out design. It is not ideal to add authentication functions in an ad-hoc manner.

You can still do authentication with BackboneFire, and many do. BackboneFire is just an adapter for Firebase and Backbone Models and Collections. The reference is still exposed for you to use it for whatever you need.

BackboneFire doesn't have an API for querying, but it doesn't stop you from passing a queried reference into a Model or Collection. The same can go for authenticated references.

I appreciate you taking the time to send in a PR. In the future if you would like to add a feature it would be best to open an issue and discuss it with us first.

@carnevalle
Copy link
Author

I understand your concerns, but how do you prefer to discuss features? I actually was trying to open an issue with you :-)

I first opened an issue that was closed and then I went back to think about the problem and created this proposal for the feature of custom auth and added an example of usage.

In my experience this makes it easier to discuss an implementation.

@davideast
Copy link
Contributor

I added an issue to discuss adding custom logic before the initial data sync occurs. #134

Providing this type of customization would allow room for authentication.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants