@annalib/anna-cognito-lib 2.2.26 → 2.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -293,13 +293,11 @@ class AnnaLibAuthService {
293
293
  confirmResetPassword({ username: this.consumingProjectAuthService.userName, newPassword: newPassword, confirmationCode: confirmationCode }).then((response) => {
294
294
  this.expiryAllExistingCurrentSession(this.consumingProjectAuthService.userName, newPassword);
295
295
  }, (err) => {
296
- console.log(err);
297
296
  this.noOfAttempts = this.noOfAttempts + 1;
298
297
  this.verifyAndSetNewPasswordErrorMessage = this.forgotPasswordError(err, this.noOfAttempts);
299
298
  });
300
299
  }
301
300
  catch (err) {
302
- console.log(err);
303
301
  this.noOfAttempts = this.noOfAttempts + 1;
304
302
  this.verifyAndSetNewPasswordErrorMessage = this.forgotPasswordError(err, this.noOfAttempts);
305
303
  }
@@ -308,18 +306,19 @@ class AnnaLibAuthService {
308
306
  }
309
307
  }
310
308
  forgotPasswordError(err, noOfAttempts) {
311
- let errorMessage;
312
- switch (err) {
313
- case "LimitExceededException":
314
- this.sessionLocked = true;
315
- errorMessage = LoginConstant.attemptLimitExceeded;
316
- break;
317
- case "ExpiredCodeException":
318
- errorMessage = LoginConstant.sessionExpired;
319
- this.verifyAndSetNewPasswordButton = LoginConstant.regenerateOtp;
320
- break;
321
- default:
322
- errorMessage = LoginConstant.attempt + " " + noOfAttempts + LoginConstant.attemptMessage;
309
+ let errorMessage = '';
310
+ console.log(err);
311
+ let errorThrown = JSON.stringify(err);
312
+ if (errorThrown.includes("LimitExceededException")) {
313
+ this.sessionLocked = true;
314
+ errorMessage = LoginConstant.attemptLimitExceeded;
315
+ }
316
+ else if (errorThrown.includes("ExpiredCodeException")) {
317
+ errorMessage = LoginConstant.sessionExpired;
318
+ this.verifyAndSetNewPasswordButton = LoginConstant.regenerateOtp;
319
+ }
320
+ else {
321
+ errorMessage = LoginConstant.attempt + " " + noOfAttempts + LoginConstant.attemptMessage;
323
322
  }
324
323
  return errorMessage;
325
324
  }