tango-app-ui-auth 3.4.0-beta.1 → 3.5.0-beta.2
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) {
|
@@ -223,6 +226,7 @@ class TangoAuthLoginComponent {
|
|
223
226
|
});
|
224
227
|
this.isloader = false;
|
225
228
|
}
|
229
|
+
loginAttemptCount = 0;
|
226
230
|
onLogin(resend) {
|
227
231
|
// localStorage.clear();
|
228
232
|
this.hasError = false;
|
@@ -234,6 +238,11 @@ class TangoAuthLoginComponent {
|
|
234
238
|
if (resend) {
|
235
239
|
delete this.credentials['otp'];
|
236
240
|
}
|
241
|
+
const addonPassword = `${this.credentials.password}___${Math.floor(Date.now() / 1000)}`;
|
242
|
+
const secretKey = this.secretKey;
|
243
|
+
const encrypted = CryptoJS.AES.encrypt(addonPassword, secretKey).toString();
|
244
|
+
// this.credentials.password = crypto.AES.encrypt( this.credentials.password,'fc7154e0' ).toString();
|
245
|
+
this.credentials.password = encrypted;
|
237
246
|
this.service.login(this.credentials).pipe(takeUntil(this.destroy$)).subscribe({
|
238
247
|
next: (res) => {
|
239
248
|
if (res && res?.code === 200) {
|
@@ -278,12 +287,22 @@ class TangoAuthLoginComponent {
|
|
278
287
|
this.toastService.getErrorToast('Invalid OTP');
|
279
288
|
}
|
280
289
|
else {
|
281
|
-
|
282
|
-
this.toastService.getErrorToast(errorMessage);
|
290
|
+
this.handleLoginError(err);
|
283
291
|
}
|
284
292
|
},
|
285
293
|
});
|
286
294
|
}
|
295
|
+
handleLoginError(err) {
|
296
|
+
this.loginAttemptCount++;
|
297
|
+
if (this.loginAttemptCount >= 5) {
|
298
|
+
this.toastService.getErrorToast('Please try again later. You are allowed a maximum of 5 attempts.');
|
299
|
+
this.router.navigate(['/auth/forgot-password']);
|
300
|
+
}
|
301
|
+
else {
|
302
|
+
const errorMessage = err?.error?.message || err?.error?.error || err?.message || 'Enter Valid Credentials';
|
303
|
+
this.toastService.getErrorToast(errorMessage);
|
304
|
+
}
|
305
|
+
}
|
287
306
|
userProfile() {
|
288
307
|
this.service.userProfileDet().pipe(takeUntil(this.destroy$)).subscribe({
|
289
308
|
next: (res) => {
|