Add more error handling for authenticate
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/9b77baca Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/9b77baca Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/9b77baca Branch: refs/heads/add-documentation Commit: 9b77baca7b8aa13d2a9f8450e13c89e07e16d422 Parents: d0cbb29 Author: Boyan Bakov <[email protected]> Authored: Tue Feb 2 13:22:45 2016 +0200 Committer: Boyan Bakov <[email protected]> Committed: Tue Feb 2 13:22:45 2016 +0200 ---------------------------------------------------------------------- lib/mpin.js | 9 +++++++++ 1 file changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/9b77baca/lib/mpin.js ---------------------------------------------------------------------- diff --git a/lib/mpin.js b/lib/mpin.js index f548cdf..3d09851 100644 --- a/lib/mpin.js +++ b/lib/mpin.js @@ -29,6 +29,9 @@ var mpinjs = (function () { Errors.wrongFlow = {code: 6, type: "WRONG_FLOW"}; Errors.userRevoked = {code: 7, type: "USER_REVOKED"}; Errors.timeoutFinish = {code: 8, type: "TIMEOUT_FINISH"}; + Errors.requestExpired = {code: 9, type: "REQUEST_EXPIRED"}; + Errors.identityNotAuthorized = {code: 10, type: "IDENTITY_NOT_AUTHORIZED"}; + Errors.incorrectAccessNumber = {code: 11, type: "INCORRECT_ACCESS_NUMBER"}; States.invalid = "INVALID"; States.start = "STARTED"; @@ -422,9 +425,15 @@ var mpinjs = (function () { if (authErr) { if (authErr.status === 401) { return cb(Errors.wrongPin, null); + } else if (authErr.status === 403) { + return cb(Errors.identityNotAuthorized, null); + } else if (authErr.status === 408) { + return cb(Errors.requestExpired, null); } else if (authErr.status === 410) { opts.userId && self.addToUser(opts.userId, {state: States.block}); return cb(Errors.wrongPin, null); + } else if (authErr.status === 412) { + return cb(Errors.incorrectAccessNumber, null); } else { return cb(Errors.wrongPin, null); }
