This repository was archived by the owner on Dec 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
This repository was archived by the owner on Dec 12, 2018. It is now read-only.
GoogleAuthFactor getMostRecentChallenge() bug #580
Copy link
Copy link
Open
Labels
Description
I think there is a bug in the GoogleAuthenticatorFactor's getMostRecentChallenge() method. Code to reproduce:
'use strict';
var stormpath = require('stormpath');
var client = new stormpath.Client({
apiKey : {
"id": $ID,
"secret": $SECRET
}
});
var applicationHref = "https://api.stormpath.com/v1/applications/$APP_ID";
var accountHref = "https://api.stormpath.com/v1/accounts/$ACCT_ID";
client.getApplication(applicationHref, function(err, application){
client.getAccount(accountHref, function (err, account) {
var collectionQueryOptions = {
type: 'google-authenticator'
};
var factor = {
type: 'google-authenticator',
accountName: '$ACCT_EMAIL_ADDRESS',
issuer: '$NAME_OF_APP'
};
// Create initial factor for account
account.createFactor(factor, function(err, googleAuthenticatorFactor) {
if (err) {
return console.log(err);
}
console.log(googleAuthenticatorFactor);
});
// Get all google-auth factors for the account
account.getFactors(collectionQueryOptions, function(err, CollectionResource) {
if (err) {
return console.log(err);
}
var googleAuthenticatorFactor = CollectionResource.items[0];
// Create google-auth challenge
googleAuthenticatorFactor.createChallenge(function(err, createdChallenge) {
if (err) {
return console.log(err);
}
console.log(createdChallenge);
// Try to get the most recently created challenge.
// This is always returning null for me
googleAuthenticatorFactor.getMostRecentChallenge(function(err, challenge){
if (err) {
return console.log(err);
}
if (challenge === null) {
return console.log('Challenge has not been created');
}
console.log('Most recent challenge:', challenge);
});
});
});
});
});
EDIT: In REST, mostRecentChallenge() is updated right after a challenge is created. In this SDK, the cached version is being used and never getting updated.