Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AuthClass.prototype.confirmSignIn = function (user, code, mfaType) {
var _this = this;
if (!code) {
return Promise.reject('Code cannot be empty');
}
var that = this;
return new Promise(function (resolve, reject) {
user.sendMFACode(code, {
onSuccess: function (session) { return __awaiter(_this, void 0, void 0, function () {
var cred, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
logger.debug(session);
_a.label = 1;
case 1:
_a.trys.push([1, 3, 4, 5]);
return [4 /*yield*/, that._setCredentialsFromSession(session)];
case 2:
cred = _a.sent();
logger.debug('succeed to get cognito credentials', cred);
return [3 /*break*/, 5];
case 3:
e_3 = _a.sent();
logger.debug('cannot get cognito credentials', e_3);
return [3 /*break*/, 5];
case 4:
that.user = user;
dispatchAuthEvent('signIn', user);
resolve(user);
return [7 /*endfinally*/];
case 5: return [2 /*return*/];
}
});
}); },
onFailure: function (err) {
logger.debug('confirm signIn failure', err);
reject(err);
}
}, mfaType);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment