Skip to content
Snippets Groups Projects
Commit 1b6fb2ca authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Adding checkAuthentication to BrowserIDIdentities.

This does no syncing if the user is authenticated.
parent 7f49bb7c
No related branches found
No related tags found
No related merge requests found
......@@ -263,6 +263,23 @@ var BrowserIDIdentities = (function() {
}
},
/**
* Check whether the current user is authenticated.
* @method checkAuthentication
* @param {function} [onSuccess] - Called when check is complete with one
* boolean parameter, authenticated. authenticated will be true if user is
* authenticated, false otw.
* @param {function} [onFailure] - Called on failure.
*/
checkAuthentication: function(onSuccess, onFailure) {
network.checkAuth(function(authenticated) {
setAuthenticationStatus(authenticated);
if (onSuccess) {
onSuccess(authenticated);
}
}, onFailure);
},
/**
* Check whether the current user is authenticated. If authenticated, sync
* identities.
......
......@@ -253,12 +253,35 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden
});
test("checkAuthentication with valid authentication", function() {
credentialsValid = true;
BrowserIDIdentities.checkAuthentication(function(authenticated) {
equal(authenticated, true, "We are authenticated!");
start();
});
stop();
});
test("checkAuthentication with invalid authentication", function() {
credentialsValid = false;
BrowserIDIdentities.checkAuthentication(function(authenticated) {
equal(authenticated, false, "We are not authenticated!");
start();
});
stop();
});
test("checkAuthenticationAndSync with valid authentication", function() {
credentialsValid = true;
BrowserIDIdentities.checkAuthenticationAndSync(function onSuccess() {},
function onComplete(authenticated) {
ok(authenticated, true, "We are authenticated!");
equal(authenticated, true, "We are authenticated!");
start();
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment