Skip to content

Commit 041c7ce

Browse files
committed
Merge pull request #1 from builddigital/auth_anonymously
add authAnonymously support
2 parents 0ff7fbf + 19d669f commit 041c7ce

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

dist/bundle.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ return /******/ (function(modules) { // webpackBootstrap
385385
}, settings);
386386
}
387387

388+
function _authAnonymously(fn) {
389+
var ref = new Firebase('' + baseUrl);
390+
return ref.authAnonymously(function (error, authData) {
391+
return fn(error, authData);
392+
});
393+
}
394+
388395
function _onAuth(fn) {
389396
var ref = new Firebase('' + baseUrl);
390397
return ref.onAuth(fn);
@@ -474,6 +481,9 @@ return /******/ (function(modules) { // webpackBootstrap
474481
authWithOAuthRedirect: function authWithOAuthRedirect(provider, fn, settings) {
475482
return _authWithOAuthRedirect(provider, fn, settings);
476483
},
484+
authAnonymously: function authAnonymously(fn) {
485+
return _authAnonymously(fn);
486+
},
477487
onAuth: function onAuth(fn) {
478488
return _onAuth(fn);
479489
},

src/rebase.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ module.exports = (function(){
289289
firebaseListeners = {};
290290
};
291291

292-
function _authWithPassword(credentials ,fn){
292+
function _authWithPassword(credentials, fn){
293293
var ref = new Firebase(`${baseUrl}`);
294294
return ref.authWithPassword(credentials, function(error, authData){
295295
return fn(error, authData);
@@ -327,6 +327,13 @@ module.exports = (function(){
327327
}, settings);
328328
}
329329

330+
function _authAnonymously(fn){
331+
var ref = new Firebase(`${baseUrl}`);
332+
return ref.authAnonymously(function(error, authData) {
333+
return fn(error, authData);
334+
});
335+
}
336+
330337
function _onAuth(fn){
331338
var ref = new Firebase(`${baseUrl}`);
332339
return ref.onAuth(fn);
@@ -416,6 +423,9 @@ module.exports = (function(){
416423
authWithOAuthRedirect(provider, fn, settings){
417424
return _authWithOAuthRedirect(provider, fn, settings);
418425
},
426+
authAnonymously(fn){
427+
return _authAnonymously(fn);
428+
},
419429
onAuth(fn){
420430
return _onAuth(fn);
421431
},

tests/specs/re-base.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,14 @@ describe('re-base Tests:', function(){
976976
expect(authData).not.toBeNull();
977977
done();
978978
});
979-
});
979+
it('can log in anonymously', function(done){
980+
base.authAnonymously(function(error, authData) {
981+
expect(error).not.toBeNull();
982+
expect(authData).toBeUndefined();
983+
done();
984+
});
985+
});
986+
});
980987
describe('User tests', function() {
981988
it('Fails to create with invalid email', function(done) {
982989
base.createUser({

0 commit comments

Comments
 (0)