@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Inject, Directive, Input, Component, EventEmitter, Output, NgModule } from '@angular/core';
|
|
3
3
|
import { __awaiter } from 'tslib';
|
|
4
|
-
import {
|
|
4
|
+
import { CognitoUserPool, CognitoUser, AuthenticationDetails } from 'amazon-cognito-identity-js';
|
|
5
5
|
import * as i3 from '@angular/router';
|
|
6
6
|
import { RouterModule } from '@angular/router';
|
|
7
7
|
import * as i3$1 from '@angular/common/http';
|
|
@@ -69,6 +69,30 @@ const CONFIG_SERVICE_TOKEN = new InjectionToken('Cognito config service token');
|
|
|
69
69
|
/** Token to inject the auth service */
|
|
70
70
|
const AUTH_SERVICE_TOKEN = new InjectionToken('Auth service token');
|
|
71
71
|
|
|
72
|
+
class AuthenticationData {
|
|
73
|
+
constructor(Username, Password) {
|
|
74
|
+
this.Username = Username;
|
|
75
|
+
this.Password = Password;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class UserPoolInformation {
|
|
79
|
+
constructor(UserPoolId, ClientId) {
|
|
80
|
+
this.UserPoolId = UserPoolId;
|
|
81
|
+
this.ClientId = ClientId;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class UsernameInfo {
|
|
85
|
+
constructor(object) {
|
|
86
|
+
this.isUsernameAvailable = object.isUsernameAvailable;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class UserState {
|
|
90
|
+
constructor(userState) {
|
|
91
|
+
this.userStatus = userState;
|
|
92
|
+
this.isUserWithTempPassword = userState == 'FORCE_CHANGE_PASSWORD';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
72
96
|
/** Token to inject the acl service */
|
|
73
97
|
const ACL_SERVICE_TOKEN = new InjectionToken('ACL service token');
|
|
74
98
|
|
|
@@ -99,7 +123,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
99
123
|
} });
|
|
100
124
|
|
|
101
125
|
class AnnaLibAuthService {
|
|
102
|
-
// authIdFromOktaRedirectionUrl: string;
|
|
103
126
|
constructor(router, aclService, httpClient, toastr, consumingProjectAuthService, consumingProjectConfigService) {
|
|
104
127
|
this.router = router;
|
|
105
128
|
this.aclService = aclService;
|
|
@@ -114,178 +137,171 @@ class AnnaLibAuthService {
|
|
|
114
137
|
}
|
|
115
138
|
}
|
|
116
139
|
ngOnInit() { }
|
|
140
|
+
/***
|
|
141
|
+
1. takes user pool data (userPool ID and client ID)
|
|
142
|
+
2. if current user is null then it means user already logged out then simply return Promise<false>
|
|
143
|
+
3. if current user present check if token is valid for it.
|
|
144
|
+
*/
|
|
117
145
|
isUserLoggedIn() {
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
let currentUser = this.getCurrentUserDetails();
|
|
147
|
+
if (currentUser) {
|
|
120
148
|
return new Promise((resolve, reject) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
149
|
+
currentUser && currentUser.getSession((error, token) => {
|
|
150
|
+
if (token) {
|
|
151
|
+
this.getAllCognitoTokenAndGroups(token);
|
|
152
|
+
resolve(true);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.toastr.error(LoginConstant.sessionExpiredError);
|
|
156
|
+
this.sessionTimeout();
|
|
157
|
+
resolve(false);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
130
160
|
});
|
|
131
|
-
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return new Promise((resolve) => {
|
|
164
|
+
clearInterval(this.accessTokenTimerId);
|
|
165
|
+
resolve(false);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
132
168
|
}
|
|
133
169
|
sessionTimeout() {
|
|
134
170
|
localStorage.clear();
|
|
135
171
|
clearInterval(this.accessTokenTimerId);
|
|
136
172
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
137
173
|
}
|
|
174
|
+
refreshAccessToken() {
|
|
175
|
+
let currentUser = this.getCurrentUserDetails();
|
|
176
|
+
let accessTokenExpiration = localStorage.getItem("accessTokenExpiration");
|
|
177
|
+
let expTime = accessTokenExpiration ? parseInt(accessTokenExpiration) : 0;
|
|
178
|
+
this.accessTokenTimerId = setInterval(() => {
|
|
179
|
+
let counter = 1000;
|
|
180
|
+
let delayFunction = setTimeout(() => {
|
|
181
|
+
currentUser && currentUser.getSession((error, token) => {
|
|
182
|
+
if (token) {
|
|
183
|
+
this.getAllCognitoTokenAndGroups(token);
|
|
184
|
+
let newExpTime = this.computeTokenExpiration(this.IdToken);
|
|
185
|
+
if (newExpTime <= 0) {
|
|
186
|
+
newExpTime = 1000;
|
|
187
|
+
counter = 0;
|
|
188
|
+
if (delayFunction) {
|
|
189
|
+
clearInterval(delayFunction);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
expTime = newExpTime;
|
|
193
|
+
localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
194
|
+
clearInterval(this.accessTokenTimerId);
|
|
195
|
+
this.refreshAccessToken();
|
|
196
|
+
}
|
|
197
|
+
else if (error.code === "NotAuthorizedException") {
|
|
198
|
+
this.toastr.error(LoginConstant.sessionExpiredError);
|
|
199
|
+
this.sessionTimeout();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}, counter);
|
|
203
|
+
}, expTime);
|
|
204
|
+
}
|
|
138
205
|
computeTokenExpiration(token) {
|
|
139
206
|
let currentTime = Math.floor(Date.now() / 1000);
|
|
140
207
|
let tokenTime = token.payload.exp;
|
|
141
208
|
let expTime = (tokenTime - currentTime) * 1000;
|
|
142
209
|
return expTime;
|
|
143
210
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
211
|
+
getCurrentUserDetails() {
|
|
212
|
+
let poolData = new UserPoolInformation(this.consumingProjectConfigService.appGenericConfig.cognito.userPoolId, this.consumingProjectConfigService.appGenericConfig.cognito.clientId);
|
|
213
|
+
let userPool = new CognitoUserPool(poolData);
|
|
214
|
+
return userPool.getCurrentUser();
|
|
215
|
+
}
|
|
216
|
+
getCognitoUserDetails(email) {
|
|
217
|
+
this.poolData = new UserPoolInformation(this.consumingProjectConfigService.appGenericConfig.cognito.userPoolId, this.consumingProjectConfigService.appGenericConfig.cognito.clientId);
|
|
218
|
+
this.userPool = new CognitoUserPool(this.poolData);
|
|
219
|
+
let userData = {
|
|
220
|
+
Username: email,
|
|
221
|
+
Pool: this.userPool,
|
|
222
|
+
};
|
|
223
|
+
let cognitoUser = new CognitoUser(userData);
|
|
224
|
+
return cognitoUser;
|
|
148
225
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.router.navigate([LoginConstant.setNewPasswordUrl]);
|
|
167
|
-
this.setNewPasswordErrorMessage = null;
|
|
168
|
-
break;
|
|
169
|
-
case "RESET_PASSWORD":
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
226
|
+
authenticate(email, password) {
|
|
227
|
+
this.loginErrorMessage = null;
|
|
228
|
+
let authData = new AuthenticationData(email, password);
|
|
229
|
+
this.authenticationDetails = new AuthenticationDetails(authData);
|
|
230
|
+
this.cognitoUser = this.getCognitoUserDetails(email);
|
|
231
|
+
this.CognitoAuthentication(this.authenticationDetails);
|
|
232
|
+
}
|
|
233
|
+
CognitoAuthentication(authenticationDetails) {
|
|
234
|
+
this.cognitoUser.authenticateUser(authenticationDetails, {
|
|
235
|
+
onSuccess: (result) => __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
let newExpTime = this.computeTokenExpiration(result.getIdToken());
|
|
237
|
+
localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
238
|
+
this.refreshAccessToken();
|
|
239
|
+
this.getAllCognitoTokenAndGroups(result);
|
|
240
|
+
yield this.consumingProjectAuthService.onSuccessfulAuthenticatingUser(result);
|
|
241
|
+
}),
|
|
242
|
+
onFailure: (err) => {
|
|
174
243
|
this.consumingProjectAuthService.isLoggingIn = false;
|
|
175
|
-
if (
|
|
244
|
+
if (err.message == LoginConstant.tempPasswordExpiryError) {
|
|
176
245
|
this.loginErrorMessage = LoginConstant.tempPasswordOnExpiryErrorMsg;
|
|
177
|
-
this.consumingProjectAuthService.sendRegenerationEmail(
|
|
246
|
+
this.consumingProjectAuthService.sendRegenerationEmail(this.authenticationDetails.getUsername());
|
|
178
247
|
}
|
|
179
|
-
else if (
|
|
248
|
+
else if (err.message === "Password attempts exceeded") {
|
|
180
249
|
this.loginErrorMessage = LoginConstant.attemptLimitExceeded;
|
|
181
250
|
}
|
|
182
251
|
else {
|
|
183
252
|
this.loginErrorMessage = LoginConstant.userNamePasswordIncorrect;
|
|
184
253
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.IdToken = token.idToken;
|
|
192
|
-
if ("cognito:groups" in token.accessToken.payload) {
|
|
193
|
-
let userGroupsInCognitoJWT = token.accessToken.payload["cognito:groups"];
|
|
194
|
-
this.aclService.userGroupsInCognitoJWT = userGroupsInCognitoJWT;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
this.aclService.userGroupsInCognitoJWT = [];
|
|
198
|
-
}
|
|
254
|
+
},
|
|
255
|
+
newPasswordRequired: (data) => {
|
|
256
|
+
this.consumingProjectAuthService.isLoggingIn = false;
|
|
257
|
+
this.userAttribute = data;
|
|
258
|
+
this.router.navigate([LoginConstant.setNewPasswordUrl]);
|
|
259
|
+
},
|
|
199
260
|
});
|
|
200
261
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// // currentUser && currentUser.getSession((error: any, token: CognitoUserSession | null) => {
|
|
209
|
-
// let session = await fetchAuthSession();
|
|
210
|
-
// if (session.tokens) {
|
|
211
|
-
// this.getAllCognitoTokenAndGroups(session.tokens);
|
|
212
|
-
// let newExpTime = this.computeTokenExpiration(this.IdToken);
|
|
213
|
-
// if (newExpTime <= 0) {
|
|
214
|
-
// newExpTime = 1000;
|
|
215
|
-
// counter = 0;
|
|
216
|
-
// if (delayFunction) {
|
|
217
|
-
// clearInterval(delayFunction);
|
|
218
|
-
// }
|
|
219
|
-
// }
|
|
220
|
-
// expTime = newExpTime;
|
|
221
|
-
// localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
222
|
-
// clearInterval(this.accessTokenTimerId);
|
|
223
|
-
// this.refreshAccessToken();
|
|
224
|
-
// } else if (error.code === "NotAuthorizedException") {
|
|
225
|
-
// this.toastr.error(LoginConstant.sessionExpiredError);
|
|
226
|
-
// this.sessionTimeout();
|
|
227
|
-
// }
|
|
228
|
-
// });
|
|
229
|
-
// // }, counter);
|
|
230
|
-
// // }, expTime);
|
|
231
|
-
}
|
|
232
|
-
changePassword(newPassword) {
|
|
233
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
try {
|
|
235
|
-
let session = yield fetchAuthSession();
|
|
236
|
-
console.log(session);
|
|
237
|
-
let oldPassword = this.userPassword;
|
|
238
|
-
let inputParam = {
|
|
239
|
-
challengeResponse: newPassword,
|
|
240
|
-
options: {
|
|
241
|
-
email: 'email@email'
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
const data = yield confirmSignIn(inputParam);
|
|
245
|
-
const { username } = yield getCurrentUser();
|
|
246
|
-
console.log(data);
|
|
262
|
+
setNewPassword(newPassword) {
|
|
263
|
+
delete this.userAttribute.email;
|
|
264
|
+
delete this.userAttribute.email_verified;
|
|
265
|
+
delete this.userAttribute.phone_number_verified;
|
|
266
|
+
this.cognitoUser.completeNewPasswordChallenge(newPassword, this.userAttribute, {
|
|
267
|
+
onSuccess: (result) => {
|
|
268
|
+
let username = this.cognitoUser.getUsername();
|
|
247
269
|
this.consumingProjectAuthService.onPasswordUpdate(username);
|
|
248
270
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
249
271
|
this.consumingProjectAuthService.newPasswordSetThenUpdateToBackend(username);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
console.log(err);
|
|
272
|
+
},
|
|
273
|
+
onFailure: (error) => {
|
|
253
274
|
this.setNewPasswordErrorMessage = LoginConstant.sessionExpired;
|
|
254
275
|
this.setNewPasswordButtonMessage = LoginConstant.loginAgain;
|
|
255
|
-
}
|
|
276
|
+
},
|
|
256
277
|
});
|
|
257
278
|
}
|
|
258
279
|
onForgotPasswordGenerateOTP(email) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
try {
|
|
264
|
-
let result = yield resetPassword({ username });
|
|
280
|
+
this.userName = email;
|
|
281
|
+
this.cognitoUser = this.getCognitoUserDetails(email);
|
|
282
|
+
this.cognitoUser.forgotPassword({
|
|
283
|
+
onSuccess: (result) => {
|
|
265
284
|
this.verifyAndSetNewPasswordMessage =
|
|
266
285
|
LoginConstant.verifyAndSetNewPasswordMessage +
|
|
267
|
-
|
|
286
|
+
result.CodeDeliveryDetails.Destination +
|
|
268
287
|
LoginConstant.pleaseEnterItBelow;
|
|
269
288
|
this.router.navigate([LoginConstant.verifyAndSetNewPasswordUrl]);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
}
|
|
289
|
+
},
|
|
290
|
+
onFailure: (err) => { },
|
|
273
291
|
});
|
|
274
292
|
}
|
|
275
|
-
verifyCode(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
try {
|
|
279
|
-
confirmResetPassword({ username, newPassword, confirmationCode });
|
|
280
|
-
this.consumingProjectAuthService.onPasswordUpdate(username);
|
|
281
|
-
this.expiryAllExistingCurrentSession(username, newPassword);
|
|
282
|
-
}
|
|
283
|
-
catch (err) {
|
|
284
|
-
console.log(err);
|
|
293
|
+
verifyCode(verificationCode, newPassword) {
|
|
294
|
+
this.cognitoUser.confirmPassword(verificationCode, newPassword, {
|
|
295
|
+
onFailure: (error) => {
|
|
285
296
|
this.noOfAttempts = this.noOfAttempts + 1;
|
|
286
|
-
this.verifyAndSetNewPasswordErrorMessage = this.forgotPasswordError(
|
|
297
|
+
this.verifyAndSetNewPasswordErrorMessage = this.forgotPasswordError(error, this.noOfAttempts);
|
|
287
298
|
this.forgotPasswordAndGlobalSignoutLoader = false;
|
|
288
|
-
}
|
|
299
|
+
},
|
|
300
|
+
onSuccess: () => {
|
|
301
|
+
let username = this.cognitoUser.getUsername();
|
|
302
|
+
this.consumingProjectAuthService.onPasswordUpdate(username);
|
|
303
|
+
this.expiryAllExistingCurrentSession(newPassword);
|
|
304
|
+
},
|
|
289
305
|
});
|
|
290
306
|
}
|
|
291
307
|
forgotPasswordError(err, noOfAttempts) {
|
|
@@ -304,51 +320,45 @@ class AnnaLibAuthService {
|
|
|
304
320
|
}
|
|
305
321
|
return errorMessage;
|
|
306
322
|
}
|
|
307
|
-
|
|
308
|
-
this.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
console.log('error signing out: ', error);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
323
|
+
getAllCognitoTokenAndGroups(token) {
|
|
324
|
+
this.accessToken = token.getAccessToken().getJwtToken();
|
|
325
|
+
this.IdToken = token.getIdToken();
|
|
326
|
+
if ("cognito:groups" in token.getAccessToken().payload) {
|
|
327
|
+
this.aclService.userGroupsInCognitoJWT = token.getAccessToken().payload["cognito:groups"];
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
this.aclService.userGroupsInCognitoJWT = [];
|
|
331
|
+
}
|
|
319
332
|
}
|
|
320
|
-
expiryAllExistingCurrentSession(
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
333
|
+
expiryAllExistingCurrentSession(newPassword) {
|
|
334
|
+
let username = this.cognitoUser.getUsername();
|
|
335
|
+
this.setUserDetails(username, newPassword);
|
|
336
|
+
this.onLoginInCogntioToGetAccessToken();
|
|
323
337
|
}
|
|
324
|
-
setUserDetails() {
|
|
338
|
+
setUserDetails(username, newPassword) {
|
|
325
339
|
this.loginErrorMessage = null;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
catch (error) { }
|
|
340
|
+
let authData = new AuthenticationData(username, newPassword);
|
|
341
|
+
this.authenticationDetails = new AuthenticationDetails(authData);
|
|
342
|
+
this.cognitoUser = this.getCognitoUserDetails(username);
|
|
343
|
+
}
|
|
344
|
+
onLoginInCogntioToGetAccessToken() {
|
|
345
|
+
this.cognitoUser.authenticateUser(this.authenticationDetails, {
|
|
346
|
+
onSuccess: (result) => __awaiter(this, void 0, void 0, function* () {
|
|
347
|
+
this.getAllCognitoTokenAndGroups(result);
|
|
348
|
+
this.onCallGlobalSignout();
|
|
349
|
+
}),
|
|
350
|
+
onFailure: (err) => { },
|
|
351
|
+
newPasswordRequired: (data) => { },
|
|
340
352
|
});
|
|
341
353
|
}
|
|
342
354
|
onCallGlobalSignout() {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
355
|
+
this.cognitoUser.globalSignOut({
|
|
356
|
+
onSuccess: (result) => {
|
|
357
|
+
console.log(result);
|
|
346
358
|
this.forgotPasswordAndGlobalSignoutLoader = false;
|
|
347
359
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
console.log('error signing out: ', error);
|
|
351
|
-
}
|
|
360
|
+
},
|
|
361
|
+
onFailure: (err) => { }
|
|
352
362
|
});
|
|
353
363
|
}
|
|
354
364
|
}
|
|
@@ -474,17 +484,14 @@ class LoginComponent {
|
|
|
474
484
|
this.authService.consumingProjectAuthService.isLoggingIn = true;
|
|
475
485
|
const username = this.loginForm.controls['username'].value;
|
|
476
486
|
const password = this.loginForm.controls['password'].value;
|
|
477
|
-
this.authService.
|
|
478
|
-
}
|
|
479
|
-
signInWithOKTA() {
|
|
480
|
-
this.authService.signInWithOKTA();
|
|
487
|
+
this.authService.authenticate(username, password);
|
|
481
488
|
}
|
|
482
489
|
}
|
|
483
490
|
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 });
|
|
484
|
-
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
|
|
491
|
+
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" }] });
|
|
485
492
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LoginComponent, decorators: [{
|
|
486
493
|
type: Component,
|
|
487
|
-
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
|
|
494
|
+
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"] }]
|
|
488
495
|
}], ctorParameters: function () {
|
|
489
496
|
return [{ type: AnnaLibAuthService }, { type: i2.FormBuilder }, { type: undefined, decorators: [{
|
|
490
497
|
type: Inject,
|
|
@@ -607,7 +614,7 @@ class SetNewPasswordComponent {
|
|
|
607
614
|
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
608
615
|
}
|
|
609
616
|
else {
|
|
610
|
-
this.authService.
|
|
617
|
+
this.authService.setNewPassword(this.password.value);
|
|
611
618
|
}
|
|
612
619
|
}
|
|
613
620
|
}
|
|
@@ -624,30 +631,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
624
631
|
}] }];
|
|
625
632
|
} });
|
|
626
633
|
|
|
627
|
-
class AuthenticationData {
|
|
628
|
-
constructor(Username, Password) {
|
|
629
|
-
this.Username = Username;
|
|
630
|
-
this.Password = Password;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
class UserPoolInformation {
|
|
634
|
-
constructor(UserPoolId, ClientId) {
|
|
635
|
-
this.UserPoolId = UserPoolId;
|
|
636
|
-
this.ClientId = ClientId;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
class UsernameInfo {
|
|
640
|
-
constructor(object) {
|
|
641
|
-
this.isUsernameAvailable = object.isUsernameAvailable;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
class UserState {
|
|
645
|
-
constructor(userState) {
|
|
646
|
-
this.userStatus = userState;
|
|
647
|
-
this.isUserWithTempPassword = userState == 'FORCE_CHANGE_PASSWORD';
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
634
|
// Angular import statements
|
|
652
635
|
class ForgotPasswordComponent {
|
|
653
636
|
constructor(authService, fb, toastr, router, consumingProjectConfigService) {
|