Skip to content

Commit

Permalink
Added anonymous authentication to DataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
tjclement committed Sep 30, 2015
1 parent 8931195 commit af4951b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
20 changes: 15 additions & 5 deletions dist/arva-ds.js
Original file line number Diff line number Diff line change
Expand Up @@ -15291,6 +15291,7 @@ System.register("core/DataSource.js", [], function($__export) {
authWithOAuthToken: function(provider, credentials, onComplete, options) {},
authWithCustomToken: function(authToken, onComplete, options) {},
authWithPassword: function(credentials, onComplete, options) {},
authAnonymously: function(onComplete, options) {},
getAuth: function() {},
unauth: function() {},
setValueChangedCallback: function(callback) {},
Expand Down Expand Up @@ -16272,10 +16273,13 @@ System.register("datasources/SharePoint/SharePointSnapshot.js", ["github:Bizboar
}
},
numChildren: function() {
if (this._data instanceof Array)
if (this._data instanceof Array) {
return this._data.length;
else
return 1;
} else if (this._data instanceof Object) {
return ObjectHelper.getEnumerableProperties(this._data).length;
} else {
return 0;
}
}
}, {}, $__super);
}(Snapshot);
Expand Down Expand Up @@ -16655,6 +16659,7 @@ System.register("core/PrioritisedObject.js", ["npm:[email protected]", "npm:evente
on: function(event, handler) {
var context = arguments[2] !== (void 0) ? arguments[2] : this;
var haveListeners = this.listeners(event, true);
$traceurRuntime.superGet(this, PrioritisedObject.prototype, "on").call(this, event, handler, context);
switch (event) {
case 'ready':
if (this._dataSource && this._dataSource.ready) {
Expand Down Expand Up @@ -16686,7 +16691,6 @@ System.register("core/PrioritisedObject.js", ["npm:[email protected]", "npm:evente
default:
break;
}
$traceurRuntime.superGet(this, PrioritisedObject.prototype, "on").call(this, event, handler, context);
},
off: function(event, handler, context) {
if (event && (handler || context)) {
Expand Down Expand Up @@ -16881,6 +16885,9 @@ System.register("datasources/FirebaseDataSource.js", ["github:Bizboard/di.js@mas
authWithPassword: function(credentials, onComplete, options) {
return this._dataReference.authWithPassword(credentials, onComplete, options);
},
authAnonymously: function(onComplete, options) {
return this._dataReference.authAnonymously(onComplete, options);
},
getAuth: function() {
return this._dataReference.getAuth();
},
Expand Down Expand Up @@ -17081,7 +17088,7 @@ System.register("datasources/SharePointDataSource.js", ["github:Bizboard/di.js@m
},
push: function(newData) {
var pushedData = this._dataReference.set(newData);
return new SharePointDataSource(this.path()).child(pushedData['_temporary-identifier']);
return new SharePointDataSource(this.path()).child(("" + pushedData['_temporary-identifier']));
},
setWithPriority: function(newData, priority) {
newData.priority = priority;
Expand All @@ -17105,6 +17112,9 @@ System.register("datasources/SharePointDataSource.js", ["github:Bizboard/di.js@m
authWithPassword: function(credentials, onComplete, options) {
throw new Error('Not implemented');
},
authAnonymously: function(onComplete, options) {
throw new Error('Not implemented');
},
getAuth: function() {
throw new Error('Not implemented');
},
Expand Down
2 changes: 1 addition & 1 deletion dist/arva-ds.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/core/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ export class DataSource {
*/
authWithPassword(credentials, onComplete, options) { }

/**
* Authenticates all instances of this DataSource as an anonymous user.
* @param {Function} onComplete Callback, executed when login is completed either successfully or erroneously.
* On error, first argument is error message.
* On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.
* @param {Object} options Optional, additional client arguments, such as configuring session persistence.
* @returns {void}
*/
authAnonymously(onComplete, options) { }

/**
* Fetches the current user's authentication state.
* If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires.
Expand Down
12 changes: 12 additions & 0 deletions src/datasources/FirebaseDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,18 @@ export class FirebaseDataSource extends DataSource {
return this._dataReference.authWithPassword(credentials, onComplete, options);
}

/**
* Authenticates all instances of this DataSource as an anonymous user.
* @param {Function} onComplete Callback, executed when login is completed either successfully or erroneously.
* On error, first argument is error message.
* On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.
* @param {Object} options Optional, additional client arguments, such as configuring session persistence.
* @returns {void}
*/
authAnonymously(onComplete, options) {
return this._dataReference.authAnonymously(onComplete, options);
}

/**
* Fetches the current user's authentication state.
* If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires.
Expand Down
10 changes: 10 additions & 0 deletions src/datasources/SharePointDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ export class SharePointDataSource extends DataSource {
*/
authWithPassword(credentials, onComplete, options) { throw new Error('Not implemented'); }

/**
* Authenticates all instances of this DataSource as an anonymous user.
* @param {Function} onComplete Callback, executed when login is completed either successfully or erroneously.
* On error, first argument is error message.
* On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.
* @param {Object} options Optional, additional client arguments, such as configuring session persistence.
* @returns {void}
*/
authAnonymously(onComplete, options) { throw new Error('Not implemented'); }

/**
* Fetches the current user's authentication state.
* If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires.
Expand Down

0 comments on commit af4951b

Please sign in to comment.