@annalib/anna-cognito-lib 2.1.0 → 2.1.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.
- package/esm2020/lib/components/login/login.component.mjs +4 -7
- package/esm2020/lib/components/set-new-password/set-new-password.component.mjs +2 -2
- package/esm2020/lib/config/auth-service.token.mjs +1 -1
- package/esm2020/lib/services/auth.service.mjs +182 -174
- package/fesm2015/annalib-anna-cognito-lib.mjs +183 -200
- package/fesm2015/annalib-anna-cognito-lib.mjs.map +1 -1
- package/fesm2020/annalib-anna-cognito-lib.mjs +211 -207
- package/fesm2020/annalib-anna-cognito-lib.mjs.map +1 -1
- package/lib/components/login/login.component.d.ts +0 -1
- package/lib/config/auth-service.token.d.ts +0 -1
- package/lib/services/auth.service.d.ts +27 -16
- package/package.json +2 -3
|
@@ -5,7 +5,7 @@ import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angu
|
|
|
5
5
|
import * as i3$1 from '@angular/common/http';
|
|
6
6
|
import * as i3 from '@angular/router';
|
|
7
7
|
import { RouterModule } from '@angular/router';
|
|
8
|
-
import {
|
|
8
|
+
import { CognitoUserPool, CognitoUser, AuthenticationDetails } from 'amazon-cognito-identity-js';
|
|
9
9
|
import * as i4 from 'ngx-toastr';
|
|
10
10
|
import * as i4$1 from '@angular/common';
|
|
11
11
|
import { CommonModule, NgOptimizedImage } from '@angular/common';
|
|
@@ -68,6 +68,30 @@ const AUTH_SERVICE_TOKEN = new InjectionToken('Auth service token');
|
|
|
68
68
|
/** Token to inject the auth service */
|
|
69
69
|
const CONFIG_SERVICE_TOKEN = new InjectionToken('Cognito config service token');
|
|
70
70
|
|
|
71
|
+
class AuthenticationData {
|
|
72
|
+
constructor(Username, Password) {
|
|
73
|
+
this.Username = Username;
|
|
74
|
+
this.Password = Password;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class UserPoolInformation {
|
|
78
|
+
constructor(UserPoolId, ClientId) {
|
|
79
|
+
this.UserPoolId = UserPoolId;
|
|
80
|
+
this.ClientId = ClientId;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
class UsernameInfo {
|
|
84
|
+
constructor(object) {
|
|
85
|
+
this.isUsernameAvailable = object.isUsernameAvailable;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
class UserState {
|
|
89
|
+
constructor(userState) {
|
|
90
|
+
this.userStatus = userState;
|
|
91
|
+
this.isUserWithTempPassword = userState == 'FORCE_CHANGE_PASSWORD';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
/** Token to inject the acl service */
|
|
72
96
|
const ACL_SERVICE_TOKEN = new InjectionToken('ACL service token');
|
|
73
97
|
|
|
@@ -97,7 +121,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
97
121
|
|
|
98
122
|
// Angular import statements
|
|
99
123
|
class AnnaLibAuthService {
|
|
100
|
-
// authIdFromOktaRedirectionUrl: string;
|
|
101
124
|
constructor(router, aclService, httpClient, toastr, consumingProjectAuthService, consumingProjectConfigService) {
|
|
102
125
|
this.router = router;
|
|
103
126
|
this.aclService = aclService;
|
|
@@ -112,164 +135,172 @@ class AnnaLibAuthService {
|
|
|
112
135
|
}
|
|
113
136
|
}
|
|
114
137
|
ngOnInit() { }
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
138
|
+
/***
|
|
139
|
+
1. takes user pool data (userPool ID and client ID)
|
|
140
|
+
2. if current user is null then it means user already logged out then simply return Promise<false>
|
|
141
|
+
3. if current user present check if token is valid for it.
|
|
142
|
+
*/
|
|
143
|
+
isUserLoggedIn() {
|
|
144
|
+
let currentUser = this.getCurrentUserDetails();
|
|
145
|
+
if (currentUser) {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
currentUser && currentUser.getSession((error, token) => {
|
|
148
|
+
if (token) {
|
|
149
|
+
this.getAllCognitoTokenAndGroups(token);
|
|
150
|
+
resolve(true);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.toastr.error(LoginConstant.sessionExpiredError);
|
|
154
|
+
this.sessionTimeout();
|
|
155
|
+
resolve(false);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return new Promise((resolve) => {
|
|
162
|
+
clearInterval(this.accessTokenTimerId);
|
|
125
163
|
resolve(false);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
128
166
|
}
|
|
129
167
|
sessionTimeout() {
|
|
130
168
|
localStorage.clear();
|
|
131
169
|
clearInterval(this.accessTokenTimerId);
|
|
132
170
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
133
171
|
}
|
|
172
|
+
refreshAccessToken() {
|
|
173
|
+
let currentUser = this.getCurrentUserDetails();
|
|
174
|
+
let accessTokenExpiration = localStorage.getItem("accessTokenExpiration");
|
|
175
|
+
let expTime = accessTokenExpiration ? parseInt(accessTokenExpiration) : 0;
|
|
176
|
+
this.accessTokenTimerId = setInterval(() => {
|
|
177
|
+
let counter = 1000;
|
|
178
|
+
let delayFunction = setTimeout(() => {
|
|
179
|
+
currentUser && currentUser.getSession((error, token) => {
|
|
180
|
+
if (token) {
|
|
181
|
+
this.getAllCognitoTokenAndGroups(token);
|
|
182
|
+
let newExpTime = this.computeTokenExpiration(this.IdToken);
|
|
183
|
+
if (newExpTime <= 0) {
|
|
184
|
+
newExpTime = 1000;
|
|
185
|
+
counter = 0;
|
|
186
|
+
if (delayFunction) {
|
|
187
|
+
clearInterval(delayFunction);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
expTime = newExpTime;
|
|
191
|
+
localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
192
|
+
clearInterval(this.accessTokenTimerId);
|
|
193
|
+
this.refreshAccessToken();
|
|
194
|
+
}
|
|
195
|
+
else if (error.code === "NotAuthorizedException") {
|
|
196
|
+
this.toastr.error(LoginConstant.sessionExpiredError);
|
|
197
|
+
this.sessionTimeout();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}, counter);
|
|
201
|
+
}, expTime);
|
|
202
|
+
}
|
|
134
203
|
computeTokenExpiration(token) {
|
|
135
204
|
let currentTime = Math.floor(Date.now() / 1000);
|
|
136
205
|
let tokenTime = token.payload.exp;
|
|
137
206
|
let expTime = (tokenTime - currentTime) * 1000;
|
|
138
207
|
return expTime;
|
|
139
208
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
await this.consumingProjectAuthService.onSuccessfulAuthenticatingUser(session.tokens.idToken.payload.sub);
|
|
155
|
-
break;
|
|
156
|
-
case "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED":
|
|
157
|
-
this.consumingProjectAuthService.isLoggingIn = false;
|
|
158
|
-
this.userName = username;
|
|
159
|
-
this.router.navigate([LoginConstant.setNewPasswordUrl]);
|
|
160
|
-
this.setNewPasswordErrorMessage = null;
|
|
161
|
-
break;
|
|
162
|
-
case "RESET_PASSWORD":
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
this.consumingProjectAuthService.isLoggingIn = false;
|
|
168
|
-
if (error?.message == LoginConstant.tempPasswordExpiryError) {
|
|
169
|
-
this.loginErrorMessage = LoginConstant.tempPasswordOnExpiryErrorMsg;
|
|
170
|
-
this.consumingProjectAuthService.sendRegenerationEmail(username);
|
|
171
|
-
}
|
|
172
|
-
else if (error?.message === "Password attempts exceeded") {
|
|
173
|
-
this.loginErrorMessage = LoginConstant.attemptLimitExceeded;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
this.loginErrorMessage = LoginConstant.userNamePasswordIncorrect;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async getAllCognitoTokenAndGroups(token) {
|
|
181
|
-
this.accessToken = token.accessToken.toString();
|
|
182
|
-
this.IdToken = token.idToken;
|
|
183
|
-
if ("cognito:groups" in token.accessToken.payload) {
|
|
184
|
-
let userGroupsInCognitoJWT = token.accessToken.payload["cognito:groups"];
|
|
185
|
-
this.aclService.userGroupsInCognitoJWT = userGroupsInCognitoJWT;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
this.aclService.userGroupsInCognitoJWT = [];
|
|
189
|
-
}
|
|
209
|
+
getCurrentUserDetails() {
|
|
210
|
+
let poolData = new UserPoolInformation(this.consumingProjectConfigService.appGenericConfig.cognito.userPoolId, this.consumingProjectConfigService.appGenericConfig.cognito.clientId);
|
|
211
|
+
let userPool = new CognitoUserPool(poolData);
|
|
212
|
+
return userPool.getCurrentUser();
|
|
213
|
+
}
|
|
214
|
+
getCognitoUserDetails(email) {
|
|
215
|
+
this.poolData = new UserPoolInformation(this.consumingProjectConfigService.appGenericConfig.cognito.userPoolId, this.consumingProjectConfigService.appGenericConfig.cognito.clientId);
|
|
216
|
+
this.userPool = new CognitoUserPool(this.poolData);
|
|
217
|
+
let userData = {
|
|
218
|
+
Username: email,
|
|
219
|
+
Pool: this.userPool,
|
|
220
|
+
};
|
|
221
|
+
let cognitoUser = new CognitoUser(userData);
|
|
222
|
+
return cognitoUser;
|
|
190
223
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// clearInterval(this.accessTokenTimerId);
|
|
213
|
-
// this.refreshAccessToken();
|
|
214
|
-
// } else if (error.code === "NotAuthorizedException") {
|
|
215
|
-
// this.toastr.error(LoginConstant.sessionExpiredError);
|
|
216
|
-
// this.sessionTimeout();
|
|
217
|
-
// }
|
|
218
|
-
// });
|
|
219
|
-
// // }, counter);
|
|
220
|
-
// // }, expTime);
|
|
221
|
-
}
|
|
222
|
-
async changePassword(newPassword) {
|
|
223
|
-
try {
|
|
224
|
-
let session = await fetchAuthSession();
|
|
225
|
-
console.log(session);
|
|
226
|
-
let oldPassword = this.userPassword;
|
|
227
|
-
let inputParam = {
|
|
228
|
-
challengeResponse: newPassword,
|
|
229
|
-
options: {
|
|
230
|
-
email: 'email@email'
|
|
224
|
+
authenticate(email, password) {
|
|
225
|
+
this.loginErrorMessage = null;
|
|
226
|
+
let authData = new AuthenticationData(email, password);
|
|
227
|
+
this.authenticationDetails = new AuthenticationDetails(authData);
|
|
228
|
+
this.cognitoUser = this.getCognitoUserDetails(email);
|
|
229
|
+
this.CognitoAuthentication(this.authenticationDetails);
|
|
230
|
+
}
|
|
231
|
+
CognitoAuthentication(authenticationDetails) {
|
|
232
|
+
this.cognitoUser.authenticateUser(authenticationDetails, {
|
|
233
|
+
onSuccess: async (result) => {
|
|
234
|
+
let newExpTime = this.computeTokenExpiration(result.getIdToken());
|
|
235
|
+
localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
236
|
+
this.refreshAccessToken();
|
|
237
|
+
this.getAllCognitoTokenAndGroups(result);
|
|
238
|
+
await this.consumingProjectAuthService.onSuccessfulAuthenticatingUser(result);
|
|
239
|
+
},
|
|
240
|
+
onFailure: (err) => {
|
|
241
|
+
this.consumingProjectAuthService.isLoggingIn = false;
|
|
242
|
+
if (err.message == LoginConstant.tempPasswordExpiryError) {
|
|
243
|
+
this.loginErrorMessage = LoginConstant.tempPasswordOnExpiryErrorMsg;
|
|
244
|
+
this.consumingProjectAuthService.sendRegenerationEmail(this.authenticationDetails.getUsername());
|
|
231
245
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
246
|
+
else if (err.message === "Password attempts exceeded") {
|
|
247
|
+
this.loginErrorMessage = LoginConstant.attemptLimitExceeded;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.loginErrorMessage = LoginConstant.userNamePasswordIncorrect;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
newPasswordRequired: (data) => {
|
|
254
|
+
this.consumingProjectAuthService.isLoggingIn = false;
|
|
255
|
+
this.userAttribute = data;
|
|
256
|
+
this.router.navigate([LoginConstant.setNewPasswordUrl]);
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
setNewPassword(newPassword) {
|
|
261
|
+
delete this.userAttribute.email;
|
|
262
|
+
delete this.userAttribute.email_verified;
|
|
263
|
+
delete this.userAttribute.phone_number_verified;
|
|
264
|
+
this.cognitoUser.completeNewPasswordChallenge(newPassword, this.userAttribute, {
|
|
265
|
+
onSuccess: (result) => {
|
|
266
|
+
let username = this.cognitoUser.getUsername();
|
|
267
|
+
this.consumingProjectAuthService.onPasswordUpdate(username);
|
|
268
|
+
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
269
|
+
this.consumingProjectAuthService.newPasswordSetThenUpdateToBackend(username);
|
|
270
|
+
},
|
|
271
|
+
onFailure: (error) => {
|
|
272
|
+
this.setNewPasswordErrorMessage = LoginConstant.sessionExpired;
|
|
273
|
+
this.setNewPasswordButtonMessage = LoginConstant.loginAgain;
|
|
274
|
+
},
|
|
275
|
+
});
|
|
245
276
|
}
|
|
246
|
-
|
|
247
|
-
let username = email;
|
|
277
|
+
onForgotPasswordGenerateOTP(email) {
|
|
248
278
|
this.userName = email;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
279
|
+
this.cognitoUser = this.getCognitoUserDetails(email);
|
|
280
|
+
this.cognitoUser.forgotPassword({
|
|
281
|
+
onSuccess: (result) => {
|
|
282
|
+
this.verifyAndSetNewPasswordMessage =
|
|
283
|
+
LoginConstant.verifyAndSetNewPasswordMessage +
|
|
284
|
+
result.CodeDeliveryDetails.Destination +
|
|
285
|
+
LoginConstant.pleaseEnterItBelow;
|
|
286
|
+
this.router.navigate([LoginConstant.verifyAndSetNewPasswordUrl]);
|
|
287
|
+
},
|
|
288
|
+
onFailure: (err) => { },
|
|
289
|
+
});
|
|
259
290
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
291
|
+
verifyCode(verificationCode, newPassword) {
|
|
292
|
+
this.cognitoUser.confirmPassword(verificationCode, newPassword, {
|
|
293
|
+
onFailure: (error) => {
|
|
294
|
+
this.noOfAttempts = this.noOfAttempts + 1;
|
|
295
|
+
this.verifyAndSetNewPasswordErrorMessage = this.forgotPasswordError(error, this.noOfAttempts);
|
|
296
|
+
this.forgotPasswordAndGlobalSignoutLoader = false;
|
|
297
|
+
},
|
|
298
|
+
onSuccess: () => {
|
|
299
|
+
let username = this.cognitoUser.getUsername();
|
|
300
|
+
this.consumingProjectAuthService.onPasswordUpdate(username);
|
|
301
|
+
this.expiryAllExistingCurrentSession(newPassword);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
273
304
|
}
|
|
274
305
|
forgotPasswordError(err, noOfAttempts) {
|
|
275
306
|
let errorMessage;
|
|
@@ -287,46 +318,46 @@ class AnnaLibAuthService {
|
|
|
287
318
|
}
|
|
288
319
|
return errorMessage;
|
|
289
320
|
}
|
|
290
|
-
|
|
291
|
-
this.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
await signOut({ global: false });
|
|
321
|
+
getAllCognitoTokenAndGroups(token) {
|
|
322
|
+
this.accessToken = token.getAccessToken().getJwtToken();
|
|
323
|
+
this.IdToken = token.getIdToken();
|
|
324
|
+
if ("cognito:groups" in token.getAccessToken().payload) {
|
|
325
|
+
this.aclService.userGroupsInCognitoJWT = token.getAccessToken().payload["cognito:groups"];
|
|
296
326
|
}
|
|
297
|
-
|
|
298
|
-
|
|
327
|
+
else {
|
|
328
|
+
this.aclService.userGroupsInCognitoJWT = [];
|
|
299
329
|
}
|
|
300
330
|
}
|
|
301
|
-
expiryAllExistingCurrentSession(
|
|
302
|
-
this.
|
|
303
|
-
this.
|
|
331
|
+
expiryAllExistingCurrentSession(newPassword) {
|
|
332
|
+
let username = this.cognitoUser.getUsername();
|
|
333
|
+
this.setUserDetails(username, newPassword);
|
|
334
|
+
this.onLoginInCogntioToGetAccessToken();
|
|
304
335
|
}
|
|
305
|
-
setUserDetails() {
|
|
336
|
+
setUserDetails(username, newPassword) {
|
|
306
337
|
this.loginErrorMessage = null;
|
|
338
|
+
let authData = new AuthenticationData(username, newPassword);
|
|
339
|
+
this.authenticationDetails = new AuthenticationDetails(authData);
|
|
340
|
+
this.cognitoUser = this.getCognitoUserDetails(username);
|
|
341
|
+
}
|
|
342
|
+
onLoginInCogntioToGetAccessToken() {
|
|
343
|
+
this.cognitoUser.authenticateUser(this.authenticationDetails, {
|
|
344
|
+
onSuccess: async (result) => {
|
|
345
|
+
this.getAllCognitoTokenAndGroups(result);
|
|
346
|
+
this.onCallGlobalSignout();
|
|
347
|
+
},
|
|
348
|
+
onFailure: (err) => { },
|
|
349
|
+
newPasswordRequired: (data) => { },
|
|
350
|
+
});
|
|
307
351
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
catch (error) { }
|
|
320
|
-
}
|
|
321
|
-
async onCallGlobalSignout() {
|
|
322
|
-
try {
|
|
323
|
-
await signOut({ global: true });
|
|
324
|
-
this.forgotPasswordAndGlobalSignoutLoader = false;
|
|
325
|
-
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
console.log('error signing out: ', error);
|
|
329
|
-
}
|
|
352
|
+
onCallGlobalSignout() {
|
|
353
|
+
this.cognitoUser.globalSignOut({
|
|
354
|
+
onSuccess: (result) => {
|
|
355
|
+
console.log(result);
|
|
356
|
+
this.forgotPasswordAndGlobalSignoutLoader = false;
|
|
357
|
+
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
358
|
+
},
|
|
359
|
+
onFailure: (err) => { }
|
|
360
|
+
});
|
|
330
361
|
}
|
|
331
362
|
}
|
|
332
363
|
AnnaLibAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AnnaLibAuthService, deps: [{ token: i3.Router }, { token: AnnaLibAclService }, { token: i3$1.HttpClient }, { token: i4.ToastrService }, { token: AUTH_SERVICE_TOKEN }, { token: CONFIG_SERVICE_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -447,17 +478,14 @@ class LoginComponent {
|
|
|
447
478
|
this.authService.consumingProjectAuthService.isLoggingIn = true;
|
|
448
479
|
const username = this.loginForm.controls['username'].value;
|
|
449
480
|
const password = this.loginForm.controls['password'].value;
|
|
450
|
-
this.authService.
|
|
451
|
-
}
|
|
452
|
-
signInWithOKTA() {
|
|
453
|
-
this.authService.signInWithOKTA();
|
|
481
|
+
this.authService.authenticate(username, password);
|
|
454
482
|
}
|
|
455
483
|
}
|
|
456
484
|
LoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LoginComponent, deps: [{ token: AnnaLibAuthService }, { token: i2.FormBuilder }, { token: CONFIG_SERVICE_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
457
|
-
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: LoginComponent, selector: "anna-cognito-lib-login", ngImport: i0, template: "<div class=\"main\">\r\n <!-- Load login page when all constant variable are intiated otherwise it will show a glitch. that's why ngIf check of constants.forgotPassword -->\r\n <section *ngIf=\"constants.forgotPassword\">\r\n <header>\r\n <img [ngSrc]=\"consumingProjectConfigService.appGenericConfig.loginPageLogoImgUrl\" width=\"145\" height=\"50\" alt=\"Anna Logo\" priority/>\r\n </header>\r\n <article>\r\n <form [formGroup]=\"loginForm\" (ngSubmit)=\"OnLogin()\">\r\n <div id=\"alert-div\" *ngIf=\"authService.loginErrorMessage\">\r\n <span class=\"material-icons\">report</span>\r\n <p>{{ authService.loginErrorMessage }}</p>\r\n </div>\r\n\r\n <input\r\n type=\"text\"\r\n tabindex=\"1\"\r\n formControlName=\"username\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.enterEmail\"\r\n autocomplete=\"username\"\r\n autofocus\r\n />\r\n\r\n <input\r\n type=\"password\"\r\n tabindex=\"2\"\r\n formControlName=\"password\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.password\"\r\n autocomplete=\"current-password\"\r\n autofocus\r\n />\r\n\r\n <a tabindex=\"4\" [routerLink]=\"constants.forgortPasswordPageUrl\">{{ constants.forgotPassword }}</a>\r\n <button\r\n tabindex=\"3\"\r\n class=\"login-btn\"\r\n [anna-cognito-lib-SpinnerButton]=\"authService.consumingProjectAuthService.isLoggingIn\"\r\n [spinnerButtonText]=\"constants.login\"\r\n ></button>\r\n </form>\r\n
|
|
485
|
+
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: LoginComponent, selector: "anna-cognito-lib-login", ngImport: i0, template: "<div class=\"main\">\r\n <!-- Load login page when all constant variable are intiated otherwise it will show a glitch. that's why ngIf check of constants.forgotPassword -->\r\n <section *ngIf=\"constants.forgotPassword\">\r\n <header>\r\n <img [ngSrc]=\"consumingProjectConfigService.appGenericConfig.loginPageLogoImgUrl\" width=\"145\" height=\"50\" alt=\"Anna Logo\" priority/>\r\n </header>\r\n <article>\r\n <form [formGroup]=\"loginForm\" (ngSubmit)=\"OnLogin()\">\r\n <div id=\"alert-div\" *ngIf=\"authService.loginErrorMessage\">\r\n <span class=\"material-icons\">report</span>\r\n <p>{{ authService.loginErrorMessage }}</p>\r\n </div>\r\n\r\n <input\r\n type=\"text\"\r\n tabindex=\"1\"\r\n formControlName=\"username\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.enterEmail\"\r\n autocomplete=\"username\"\r\n autofocus\r\n />\r\n\r\n <input\r\n type=\"password\"\r\n tabindex=\"2\"\r\n formControlName=\"password\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.password\"\r\n autocomplete=\"current-password\"\r\n autofocus\r\n />\r\n\r\n <a tabindex=\"4\" [routerLink]=\"constants.forgortPasswordPageUrl\">{{ constants.forgotPassword }}</a>\r\n <button\r\n tabindex=\"3\"\r\n class=\"login-btn\"\r\n [anna-cognito-lib-SpinnerButton]=\"authService.consumingProjectAuthService.isLoggingIn\"\r\n [spinnerButtonText]=\"constants.login\"\r\n ></button>\r\n </form>\r\n </article>\r\n <footer>\r\n <anna-cognito-lib-powered-by-logo-template>\r\n </anna-cognito-lib-powered-by-logo-template>\r\n </footer>\r\n </section>\r\n</div>\r\n\r\n<div class=\"page-footer\">\r\n <anna-cognito-lib-surewaves-year-logo></anna-cognito-lib-surewaves-year-logo>\r\n <anna-cognito-lib-version-and-term-policy></anna-cognito-lib-version-and-term-policy>\r\n</div>\r\n", styles: ["@keyframes show{0%{opacity:0}50%{opacity:.5}to{opacity:1}}html{overflow-y:scroll}.main{background-color:#fff;background-size:cover;font-family:Roboto;height:calc(100vh - 50px)}section{top:45%;left:50%;position:absolute;transform:translate(-50%,-50%);width:20.875rem;animation:show .5s 1;-moz-animation:show .5s 1}.container{width:100%;height:100%;overflow:auto}header{height:auto;width:100%;text-align:center}article{margin-top:.9375rem;margin-bottom:.9375rem;border:1px solid #979797;background-color:#f4f4f4;padding:2rem 1.375rem;border-radius:.375rem;box-shadow:0 .125rem .4375rem #0000001a}article #heading{color:#212121;text-align:center;margin-bottom:1.5rem;font-family:Roboto;font-size:1.125rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}#alert-div{padding:.25rem 0 0;margin-bottom:.75rem;border-radius:.25rem;border:solid 1px #f9b3ae;background-color:#fde4e3}#alert-div .material-icons{color:#f44336;font-size:1rem;margin-left:.5rem}#alert-div .mdi-info{color:#268bff;font-size:1rem}#alert-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}#info-div{padding:6px 0;margin-bottom:.75rem;border-radius:.25rem;border:1px solid #268bff;background:#e3f0ff}#info-div .mdi-info{color:#268bff;font-size:1rem;margin-left:6px}#info-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}footer{align-items:baseline;color:#6e6e6e;opacity:.9;display:flex;font-family:Ubuntu;font-size:1.25rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal;justify-content:center}footer span{font-size:1.5625rem;margin-left:.25rem}input[type=password],input[type=text],input[type=number]{width:100%;height:30px;padding:.75rem 1rem;border:1px solid #979797;margin-bottom:.625rem;border-radius:.375rem}.login-btn{width:100%;height:2.5rem;border:0;color:#fff;background-color:#268bff;border-radius:.375rem;font-size:1rem;margin-top:.9375rem}.login-btn:hover{background-color:#4099ff;cursor:pointer}.login-btn:disabled{background-color:#ccc;color:#fff;cursor:not-allowed}.input-invalid{border:1px solid #fe3824!important}input[type=password].ng-dirty.ng-invalid,input[type=text].ng-dirty.ng-invalid{border:1px solid #fe3824}input[type=submit]:focus,input[type=password]:focus,input[type=text]:focus,input[type=checkbox]:focus,button:focus{outline:none}input::placeholder{color:#a4a4a4}:host ::ng-deep .verison-and-policy{color:#8bac2a}a{float:right;color:#268bff;font-family:Roboto;font-size:.875rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal;text-decoration:underline}a:hover{cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i4$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4$1.NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "loading", "priority", "loaderParams", "disableOptimizedSrcset", "fill", "src", "srcset"] }, { kind: "directive", type: SpinnerButtonDirective, selector: "[anna-cognito-lib-SpinnerButton]", inputs: ["anna-cognito-lib-SpinnerButton", "spinnerButtonText"] }, { kind: "component", type: VersionAndTermPolicyComponent, selector: "anna-cognito-lib-version-and-term-policy" }, { kind: "component", type: SurewavesYearLogoComponent, selector: "anna-cognito-lib-surewaves-year-logo" }, { kind: "component", type: PoweredByLogoTemplateComponent, selector: "anna-cognito-lib-powered-by-logo-template" }] });
|
|
458
486
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LoginComponent, decorators: [{
|
|
459
487
|
type: Component,
|
|
460
|
-
args: [{ selector: "anna-cognito-lib-login", template: "<div class=\"main\">\r\n <!-- Load login page when all constant variable are intiated otherwise it will show a glitch. that's why ngIf check of constants.forgotPassword -->\r\n <section *ngIf=\"constants.forgotPassword\">\r\n <header>\r\n <img [ngSrc]=\"consumingProjectConfigService.appGenericConfig.loginPageLogoImgUrl\" width=\"145\" height=\"50\" alt=\"Anna Logo\" priority/>\r\n </header>\r\n <article>\r\n <form [formGroup]=\"loginForm\" (ngSubmit)=\"OnLogin()\">\r\n <div id=\"alert-div\" *ngIf=\"authService.loginErrorMessage\">\r\n <span class=\"material-icons\">report</span>\r\n <p>{{ authService.loginErrorMessage }}</p>\r\n </div>\r\n\r\n <input\r\n type=\"text\"\r\n tabindex=\"1\"\r\n formControlName=\"username\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.enterEmail\"\r\n autocomplete=\"username\"\r\n autofocus\r\n />\r\n\r\n <input\r\n type=\"password\"\r\n tabindex=\"2\"\r\n formControlName=\"password\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.password\"\r\n autocomplete=\"current-password\"\r\n autofocus\r\n />\r\n\r\n <a tabindex=\"4\" [routerLink]=\"constants.forgortPasswordPageUrl\">{{ constants.forgotPassword }}</a>\r\n <button\r\n tabindex=\"3\"\r\n class=\"login-btn\"\r\n [anna-cognito-lib-SpinnerButton]=\"authService.consumingProjectAuthService.isLoggingIn\"\r\n [spinnerButtonText]=\"constants.login\"\r\n ></button>\r\n </form>\r\n
|
|
488
|
+
args: [{ selector: "anna-cognito-lib-login", template: "<div class=\"main\">\r\n <!-- Load login page when all constant variable are intiated otherwise it will show a glitch. that's why ngIf check of constants.forgotPassword -->\r\n <section *ngIf=\"constants.forgotPassword\">\r\n <header>\r\n <img [ngSrc]=\"consumingProjectConfigService.appGenericConfig.loginPageLogoImgUrl\" width=\"145\" height=\"50\" alt=\"Anna Logo\" priority/>\r\n </header>\r\n <article>\r\n <form [formGroup]=\"loginForm\" (ngSubmit)=\"OnLogin()\">\r\n <div id=\"alert-div\" *ngIf=\"authService.loginErrorMessage\">\r\n <span class=\"material-icons\">report</span>\r\n <p>{{ authService.loginErrorMessage }}</p>\r\n </div>\r\n\r\n <input\r\n type=\"text\"\r\n tabindex=\"1\"\r\n formControlName=\"username\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.enterEmail\"\r\n autocomplete=\"username\"\r\n autofocus\r\n />\r\n\r\n <input\r\n type=\"password\"\r\n tabindex=\"2\"\r\n formControlName=\"password\"\r\n [ngClass]=\"{ 'input-invalid': authService.loginErrorMessage }\"\r\n [placeholder]=\"constants.password\"\r\n autocomplete=\"current-password\"\r\n autofocus\r\n />\r\n\r\n <a tabindex=\"4\" [routerLink]=\"constants.forgortPasswordPageUrl\">{{ constants.forgotPassword }}</a>\r\n <button\r\n tabindex=\"3\"\r\n class=\"login-btn\"\r\n [anna-cognito-lib-SpinnerButton]=\"authService.consumingProjectAuthService.isLoggingIn\"\r\n [spinnerButtonText]=\"constants.login\"\r\n ></button>\r\n </form>\r\n </article>\r\n <footer>\r\n <anna-cognito-lib-powered-by-logo-template>\r\n </anna-cognito-lib-powered-by-logo-template>\r\n </footer>\r\n </section>\r\n</div>\r\n\r\n<div class=\"page-footer\">\r\n <anna-cognito-lib-surewaves-year-logo></anna-cognito-lib-surewaves-year-logo>\r\n <anna-cognito-lib-version-and-term-policy></anna-cognito-lib-version-and-term-policy>\r\n</div>\r\n", styles: ["@keyframes show{0%{opacity:0}50%{opacity:.5}to{opacity:1}}html{overflow-y:scroll}.main{background-color:#fff;background-size:cover;font-family:Roboto;height:calc(100vh - 50px)}section{top:45%;left:50%;position:absolute;transform:translate(-50%,-50%);width:20.875rem;animation:show .5s 1;-moz-animation:show .5s 1}.container{width:100%;height:100%;overflow:auto}header{height:auto;width:100%;text-align:center}article{margin-top:.9375rem;margin-bottom:.9375rem;border:1px solid #979797;background-color:#f4f4f4;padding:2rem 1.375rem;border-radius:.375rem;box-shadow:0 .125rem .4375rem #0000001a}article #heading{color:#212121;text-align:center;margin-bottom:1.5rem;font-family:Roboto;font-size:1.125rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}#alert-div{padding:.25rem 0 0;margin-bottom:.75rem;border-radius:.25rem;border:solid 1px #f9b3ae;background-color:#fde4e3}#alert-div .material-icons{color:#f44336;font-size:1rem;margin-left:.5rem}#alert-div .mdi-info{color:#268bff;font-size:1rem}#alert-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}#info-div{padding:6px 0;margin-bottom:.75rem;border-radius:.25rem;border:1px solid #268bff;background:#e3f0ff}#info-div .mdi-info{color:#268bff;font-size:1rem;margin-left:6px}#info-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}footer{align-items:baseline;color:#6e6e6e;opacity:.9;display:flex;font-family:Ubuntu;font-size:1.25rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal;justify-content:center}footer span{font-size:1.5625rem;margin-left:.25rem}input[type=password],input[type=text],input[type=number]{width:100%;height:30px;padding:.75rem 1rem;border:1px solid #979797;margin-bottom:.625rem;border-radius:.375rem}.login-btn{width:100%;height:2.5rem;border:0;color:#fff;background-color:#268bff;border-radius:.375rem;font-size:1rem;margin-top:.9375rem}.login-btn:hover{background-color:#4099ff;cursor:pointer}.login-btn:disabled{background-color:#ccc;color:#fff;cursor:not-allowed}.input-invalid{border:1px solid #fe3824!important}input[type=password].ng-dirty.ng-invalid,input[type=text].ng-dirty.ng-invalid{border:1px solid #fe3824}input[type=submit]:focus,input[type=password]:focus,input[type=text]:focus,input[type=checkbox]:focus,button:focus{outline:none}input::placeholder{color:#a4a4a4}:host ::ng-deep .verison-and-policy{color:#8bac2a}a{float:right;color:#268bff;font-family:Roboto;font-size:.875rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal;text-decoration:underline}a:hover{cursor:pointer}\n"] }]
|
|
461
489
|
}], ctorParameters: function () { return [{ type: AnnaLibAuthService }, { type: i2.FormBuilder }, { type: undefined, decorators: [{
|
|
462
490
|
type: Inject,
|
|
463
491
|
args: [CONFIG_SERVICE_TOKEN]
|
|
@@ -576,7 +604,7 @@ class SetNewPasswordComponent {
|
|
|
576
604
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
577
605
|
}
|
|
578
606
|
else {
|
|
579
|
-
this.authService.
|
|
607
|
+
this.authService.setNewPassword(this.password.value);
|
|
580
608
|
}
|
|
581
609
|
}
|
|
582
610
|
}
|
|
@@ -591,30 +619,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
591
619
|
args: [CONFIG_SERVICE_TOKEN]
|
|
592
620
|
}] }]; } });
|
|
593
621
|
|
|
594
|
-
class AuthenticationData {
|
|
595
|
-
constructor(Username, Password) {
|
|
596
|
-
this.Username = Username;
|
|
597
|
-
this.Password = Password;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
class UserPoolInformation {
|
|
601
|
-
constructor(UserPoolId, ClientId) {
|
|
602
|
-
this.UserPoolId = UserPoolId;
|
|
603
|
-
this.ClientId = ClientId;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
class UsernameInfo {
|
|
607
|
-
constructor(object) {
|
|
608
|
-
this.isUsernameAvailable = object.isUsernameAvailable;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
class UserState {
|
|
612
|
-
constructor(userState) {
|
|
613
|
-
this.userStatus = userState;
|
|
614
|
-
this.isUserWithTempPassword = userState == 'FORCE_CHANGE_PASSWORD';
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
622
|
// Angular import statements
|
|
619
623
|
class ForgotPasswordComponent {
|
|
620
624
|
constructor(authService, fb, toastr, router, consumingProjectConfigService) {
|