tango-app-ui-auth 3.5.0-beta.1 → 3.5.0-beta.3

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.
@@ -8,6 +8,7 @@ import * as i2$1 from '@angular/forms';
8
8
  import { Validators, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
9
9
  import { BehaviorSubject, of, map, catchError, throwError, Subject, takeUntil, timer } from 'rxjs';
10
10
  import dayjs from 'dayjs';
11
+ import CryptoJS from 'crypto-js';
11
12
  import * as i2 from '@angular/common/http';
12
13
  import * as i4 from 'tango-app-ui-global';
13
14
  import * as i5 from 'tango-app-ui-shared';
@@ -156,6 +157,7 @@ class TangoAuthLoginComponent {
156
157
  emailInputRef;
157
158
  passwordInputRef;
158
159
  authlocalStorageToken;
160
+ secretKey;
159
161
  destroy$ = new Subject();
160
162
  pageSection = 'login';
161
163
  otp = '';
@@ -175,6 +177,7 @@ class TangoAuthLoginComponent {
175
177
  this.gs.environment.pipe(takeUntil(this.destroy$)).subscribe((env) => {
176
178
  if (env) {
177
179
  this.authlocalStorageToken = `${env.appVersion}-${env.USERDATA_KEY}`;
180
+ this.secretKey = env.secretKey;
178
181
  }
179
182
  });
180
183
  if (this.service.currentUserValue) {
@@ -235,7 +238,11 @@ class TangoAuthLoginComponent {
235
238
  if (resend) {
236
239
  delete this.credentials['otp'];
237
240
  }
238
- // this.credentials.password = crypto.AES.encrypt( this.credentials.password,'fc7154e0' ).toString();
241
+ const originalPassword = this.credentials.password;
242
+ const addonPassword = `${this.credentials.password}___${Math.floor(Date.now() / 1000)}`;
243
+ const secretKey = this.secretKey;
244
+ const encrypted = CryptoJS.AES.encrypt(addonPassword, secretKey).toString();
245
+ this.credentials.password = encrypted;
239
246
  this.service.login(this.credentials).pipe(takeUntil(this.destroy$)).subscribe({
240
247
  next: (res) => {
241
248
  if (res && res?.code === 200) {
@@ -268,13 +275,16 @@ class TangoAuthLoginComponent {
268
275
  this.userProfile();
269
276
  }
270
277
  else if (!res || res?.code == 401) {
278
+ this.credentials.password = originalPassword;
271
279
  this.toastService.getErrorToast('Enter Valid Credentials');
272
280
  }
273
281
  else {
282
+ this.credentials.password = originalPassword;
274
283
  this.toastService.getErrorToast('Enter Valid Credentials');
275
284
  }
276
285
  },
277
286
  error: (err) => {
287
+ this.credentials.password = originalPassword;
278
288
  this.hasError = true;
279
289
  if (this.pageSection === 'otp') {
280
290
  this.toastService.getErrorToast('Invalid OTP');