fiznool / backbone.basicauth Goto Github PK
View Code? Open in Web Editor NEWHTTP Basic Authentication for Backbone.
HTTP Basic Authentication for Backbone.
Thank you for this little extension. Just what I needed. I wonder though, is it possible to get this registered with Bower?
Currently only backbone 1.0.0 is supported in bower.json which makes it difficult for any project to upgrade to backbone 1.1 since bower would complain about dependency mismatch.
If Backbone.sync is overridden by the calling app, when Backbone.BasicAuth.clear()
is called, the overridden sync is not restored - instead, the version that ships with Backbone is restored.
Reproduction:
Backbone.BasicAuth.set('user', 'pass');
var originalSync = Backbone.sync;
Backbone.sync = function(method, model, options) {
// Some extra stuff
return originalSync.call(model, method, model, options);
}
// Next line sets Backbone.sync back to the version in backbone.js,
// not the one set above
Backbone.BasicAuth.clear();
Realy needs a CommonJS Support...
Please add a license so that others may legally use this code.
(For reference, 13 of the 15 libraries we use are under MIT license)
One of the contracts of Backbone is that methods that call sync internally return the value of sync, because it is supposed to return a promise. I've noticed that on line 35 you just call the sync function, instead of returning it, and the result is that code that relies on a promise being returned does not get it.
Suggested alteration:
35: return originalSync.call(model, method, model, options);
Useful code though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.