@annalib/anna-cognito-lib 0.2.3 → 0.2.4
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/.browserslistrc +16 -0
- package/README.md +2 -3
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +14 -37
- package/src/assets/.gitkeep +0 -0
- package/src/assets/images/Anna-Logo.png +0 -0
- package/src/lib/anna-cognito-lib.module.ts +51 -0
- package/src/lib/components/forgot-password/forgot-password.component.html +44 -0
- package/src/lib/components/forgot-password/forgot-password.component.scss +22 -0
- package/src/lib/components/forgot-password/forgot-password.component.spec.ts +25 -0
- package/src/lib/components/forgot-password/forgot-password.component.ts +75 -0
- package/src/lib/components/login/login.component.html +45 -0
- package/src/lib/components/login/login.component.scss +10 -0
- package/src/lib/components/login/login.component.spec.ts +25 -0
- package/src/lib/components/login/login.component.ts +47 -0
- package/src/lib/components/password-matching/password-matching.component.html +84 -0
- package/src/lib/components/password-matching/password-matching.component.scss +83 -0
- package/src/lib/components/password-matching/password-matching.component.spec.ts +25 -0
- package/src/lib/components/password-matching/password-matching.component.ts +92 -0
- package/src/lib/components/set-new-password/set-new-password.component.html +31 -0
- package/src/lib/components/set-new-password/set-new-password.component.scss +1 -0
- package/src/lib/components/set-new-password/set-new-password.component.spec.ts +25 -0
- package/src/lib/components/set-new-password/set-new-password.component.ts +54 -0
- package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.html +54 -0
- package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.scss +40 -0
- package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.spec.ts +25 -0
- package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.ts +70 -0
- package/src/lib/config/acl-service.token.ts +22 -0
- package/src/lib/config/auth-service.token.ts +15 -0
- package/src/lib/config/library.config.ts +8 -0
- package/src/lib/constants/loginConstant.ts +50 -0
- package/{lib/directives/spinner-button/index.d.ts → src/lib/directives/spinner-button/index.ts} +0 -0
- package/src/lib/directives/spinner-button/spinner-button.directive.spec.ts +40 -0
- package/src/lib/directives/spinner-button/spinner-button.directive.ts +36 -0
- package/src/lib/models/auth.model.ts +24 -0
- package/src/lib/scss/_colors.scss +107 -0
- package/src/lib/scss/_fonts.scss +86 -0
- package/src/lib/scss/_loginTemplate.scss +164 -0
- package/src/lib/services/acl.service.ts +24 -0
- package/src/lib/services/auth.service.ts +243 -0
- package/{public-api.d.ts → src/public-api.ts} +14 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/annalib-anna-cognito-lib.d.ts +0 -5
- package/esm2020/annalib-anna-cognito-lib.mjs +0 -5
- package/esm2020/lib/anna-cognito-lib.module.mjs +0 -74
- package/esm2020/lib/components/forgot-password/forgot-password.component.mjs +0 -69
- package/esm2020/lib/components/login/login.component.mjs +0 -46
- package/esm2020/lib/components/password-matching/password-matching.component.mjs +0 -90
- package/esm2020/lib/components/set-new-password/set-new-password.component.mjs +0 -55
- package/esm2020/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.mjs +0 -66
- package/esm2020/lib/config/acl-service.token.mjs +0 -4
- package/esm2020/lib/config/auth-service.token.mjs +0 -4
- package/esm2020/lib/config/library.config.mjs +0 -6
- package/esm2020/lib/constants/loginConstant.mjs +0 -46
- package/esm2020/lib/directives/spinner-button/index.mjs +0 -2
- package/esm2020/lib/directives/spinner-button/spinner-button.directive.mjs +0 -42
- package/esm2020/lib/models/auth.model.mjs +0 -18
- package/esm2020/lib/services/acl.service.mjs +0 -30
- package/esm2020/lib/services/auth.service.mjs +0 -218
- package/esm2020/public-api.mjs +0 -21
- package/fesm2015/annalib-anna-cognito-lib.mjs +0 -705
- package/fesm2015/annalib-anna-cognito-lib.mjs.map +0 -1
- package/fesm2020/annalib-anna-cognito-lib.mjs +0 -699
- package/fesm2020/annalib-anna-cognito-lib.mjs.map +0 -1
- package/lib/anna-cognito-lib.module.d.ts +0 -18
- package/lib/components/forgot-password/forgot-password.component.d.ts +0 -31
- package/lib/components/login/login.component.d.ts +0 -21
- package/lib/components/password-matching/password-matching.component.d.ts +0 -22
- package/lib/components/set-new-password/set-new-password.component.d.ts +0 -26
- package/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.d.ts +0 -30
- package/lib/config/acl-service.token.d.ts +0 -19
- package/lib/config/auth-service.token.d.ts +0 -11
- package/lib/config/library.config.d.ts +0 -7
- package/lib/constants/loginConstant.d.ts +0 -40
- package/lib/directives/spinner-button/spinner-button.directive.d.ts +0 -15
- package/lib/models/auth.model.d.ts +0 -16
- package/lib/services/acl.service.d.ts +0 -12
- package/lib/services/auth.service.d.ts +0 -53
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { PasswordMatchingComponent } from './password-matching.component';
|
|
4
|
+
|
|
5
|
+
describe('PasswordMatchingComponent', () => {
|
|
6
|
+
let component: PasswordMatchingComponent;
|
|
7
|
+
let fixture: ComponentFixture<PasswordMatchingComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ PasswordMatchingComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(PasswordMatchingComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Angular import statements
|
|
2
|
+
import { EventEmitter, Inject, Input, Output } from "@angular/core";
|
|
3
|
+
import { Component, OnInit } from "@angular/core";
|
|
4
|
+
import { AbstractControl, FormBuilder, FormGroup, ValidationErrors, ValidatorFn, Validators } from "@angular/forms";
|
|
5
|
+
|
|
6
|
+
// Third party import statements
|
|
7
|
+
import { debounceTime } from "rxjs/operators";
|
|
8
|
+
|
|
9
|
+
// User defined import statements
|
|
10
|
+
import { LoginConstant } from "../../constants/loginConstant";
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'anna-cognito-lib-password-matching',
|
|
14
|
+
templateUrl: './password-matching.component.html',
|
|
15
|
+
styleUrls: ['./password-matching.component.scss']
|
|
16
|
+
})
|
|
17
|
+
export class PasswordMatchingComponent implements OnInit {
|
|
18
|
+
@Output() passwordChange = new EventEmitter();
|
|
19
|
+
@Output() confirmPasswordChange = new EventEmitter();
|
|
20
|
+
|
|
21
|
+
@Input() passwordNotMatching: boolean;
|
|
22
|
+
passwordForm: FormGroup;
|
|
23
|
+
constants: typeof LoginConstant;
|
|
24
|
+
constructor(@Inject(FormBuilder) private fb: FormBuilder) {}
|
|
25
|
+
|
|
26
|
+
ngOnInit() {
|
|
27
|
+
this.constants = LoginConstant;
|
|
28
|
+
this.createGroup();
|
|
29
|
+
this.formValueChanged();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
formValueChanged() {
|
|
33
|
+
const password = this.passwordForm.get("password");
|
|
34
|
+
const confirmPassword = this.passwordForm.get("confirmPassword");
|
|
35
|
+
|
|
36
|
+
password && password.valueChanges.subscribe(() => {
|
|
37
|
+
password && password.setValidators([
|
|
38
|
+
Validators.required,
|
|
39
|
+
this.regexValidator(new RegExp(".{8,}"), { minLength: true }),
|
|
40
|
+
this.regexValidator(new RegExp("[a-z]"), { lowercase: true }),
|
|
41
|
+
this.regexValidator(new RegExp("[A-Z]"), { uppercase: true }),
|
|
42
|
+
this.regexValidator(new RegExp("[0-9]"), { number: true }),
|
|
43
|
+
this.regexValidator(new RegExp("[^a-zA-Z0-9]"), { specialCharacter: true }),
|
|
44
|
+
]);
|
|
45
|
+
password.updateValueAndValidity({ emitEvent: false });
|
|
46
|
+
this.onPasswordChange();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if(confirmPassword){
|
|
50
|
+
confirmPassword.valueChanges.pipe(debounceTime(300)).subscribe(() => {
|
|
51
|
+
confirmPassword.setValidators([Validators.required]);
|
|
52
|
+
confirmPassword.updateValueAndValidity({ emitEvent: false });
|
|
53
|
+
this.onConfirmPasswordChange();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onPasswordChange() {
|
|
60
|
+
let result = {
|
|
61
|
+
value: this.passwordForm.value.password,
|
|
62
|
+
status: this.passwordForm.controls['password'].status,
|
|
63
|
+
};
|
|
64
|
+
this.passwordChange.emit(result);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onConfirmPasswordChange() {
|
|
68
|
+
let result = {
|
|
69
|
+
value: this.passwordForm.value.confirmPassword,
|
|
70
|
+
status: this.passwordForm.controls['confirmPassword'].status,
|
|
71
|
+
};
|
|
72
|
+
this.confirmPasswordChange.emit(result);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
createGroup() {
|
|
76
|
+
this.passwordForm = this.fb.group({
|
|
77
|
+
password: [null],
|
|
78
|
+
confirmPassword: [null],
|
|
79
|
+
});
|
|
80
|
+
return this.passwordForm;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// TODO: check the return again
|
|
84
|
+
regexValidator(regex: RegExp, error: ValidationErrors): any
|
|
85
|
+
{
|
|
86
|
+
return (control: AbstractControl): { [key: string]: boolean } => {
|
|
87
|
+
const valid = regex.test(control.value);
|
|
88
|
+
return (valid ? null : error) as any;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<div class="main">
|
|
2
|
+
<section>
|
|
3
|
+
<header>
|
|
4
|
+
<img src="assets/images/Anna-Logo-for-footer-min.png" alt="Anna Logo" />
|
|
5
|
+
</header>
|
|
6
|
+
<article>
|
|
7
|
+
<form>
|
|
8
|
+
<div id="heading">
|
|
9
|
+
{{ constants.setNewPasswordHeading }}
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div id="alert-div" *ngIf="authService.setNewPasswordErrorMessage">
|
|
13
|
+
<span class="material-icons">report</span>
|
|
14
|
+
<p>{{ authService.setNewPasswordErrorMessage }}</p>
|
|
15
|
+
</div>
|
|
16
|
+
<anna-cognito-lib-password-matching
|
|
17
|
+
(passwordChange)="onPasswordChange($event)"
|
|
18
|
+
(confirmPasswordChange)="onConfirmPasswordChange($event)"
|
|
19
|
+
[passwordNotMatching]="passwordNotMatching"
|
|
20
|
+
>
|
|
21
|
+
</anna-cognito-lib-password-matching>
|
|
22
|
+
<button tabindex="3" class="login-btn" [disabled]="!isFormValid()" (click)="onSettingNewPassword()">
|
|
23
|
+
{{ authService.setNewPasswordButtonMessage }}
|
|
24
|
+
</button>
|
|
25
|
+
</form>
|
|
26
|
+
</article>
|
|
27
|
+
<footer>
|
|
28
|
+
Powered by <span> <strong> SureWaves</strong></span>
|
|
29
|
+
</footer>
|
|
30
|
+
</section>
|
|
31
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../../scss/loginTemplate";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SetNewPasswordComponent } from './set-new-password.component';
|
|
4
|
+
|
|
5
|
+
describe('SetNewPasswordComponent', () => {
|
|
6
|
+
let component: SetNewPasswordComponent;
|
|
7
|
+
let fixture: ComponentFixture<SetNewPasswordComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ SetNewPasswordComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(SetNewPasswordComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
// Angular import statements
|
|
3
|
+
import { Component, OnInit } from "@angular/core";
|
|
4
|
+
import { Router } from "@angular/router";
|
|
5
|
+
|
|
6
|
+
// User defined import statements
|
|
7
|
+
import { AnnaLibAuthService } from "../../services/auth.service";
|
|
8
|
+
import { LoginConstant } from "../../constants/loginConstant";
|
|
9
|
+
type passwordType = { value: string | null, status: string | null };
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'anna-cognito-lib-set-new-password',
|
|
13
|
+
templateUrl: './set-new-password.component.html',
|
|
14
|
+
styleUrls: ['./set-new-password.component.scss']
|
|
15
|
+
})
|
|
16
|
+
export class SetNewPasswordComponent implements OnInit {
|
|
17
|
+
passwordNotMatching = false;
|
|
18
|
+
|
|
19
|
+
password: passwordType = { value: null, status: null };
|
|
20
|
+
confirmPassword: passwordType = { value: null, status: null };
|
|
21
|
+
constants: typeof LoginConstant;
|
|
22
|
+
|
|
23
|
+
constructor(public authService: AnnaLibAuthService,
|
|
24
|
+
private router: Router) {}
|
|
25
|
+
|
|
26
|
+
ngOnInit() {
|
|
27
|
+
this.constants = LoginConstant;
|
|
28
|
+
this.authService.setNewPasswordButtonMessage = LoginConstant.setNewPasswordButton;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
isFormValid() {
|
|
32
|
+
return this.password.status === "VALID" && this.confirmPassword.status === "VALID";
|
|
33
|
+
}
|
|
34
|
+
onPasswordChange($event: passwordType) {
|
|
35
|
+
this.password = $event;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onConfirmPasswordChange($event: passwordType) {
|
|
39
|
+
this.confirmPassword = $event;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onSettingNewPassword() {
|
|
43
|
+
if (this.password.value != this.confirmPassword.value) {
|
|
44
|
+
this.passwordNotMatching = true;
|
|
45
|
+
} else {
|
|
46
|
+
this.passwordNotMatching = false;
|
|
47
|
+
if (this.authService.setNewPasswordButtonMessage === LoginConstant.loginAgain) {
|
|
48
|
+
this.router.navigate([LoginConstant.loginPageUrl]);
|
|
49
|
+
} else {
|
|
50
|
+
this.authService.setNewPassword(this.password.value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.html
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<div class="main" [ngClass]="{ 'main-height': authService.verifyAndSetNewPasswordErrorMessage }">
|
|
2
|
+
<section>
|
|
3
|
+
<header>
|
|
4
|
+
<img src="assets/images/Anna-Logo-for-footer-min.png" alt="Anna Logo" />
|
|
5
|
+
</header>
|
|
6
|
+
<article>
|
|
7
|
+
<span class="back-btn" [routerLink]="constants.forgortPasswordPageUrl">
|
|
8
|
+
<i class="mdi mdi-arrow-left"></i>
|
|
9
|
+
</span>
|
|
10
|
+
|
|
11
|
+
<form [formGroup]="verifyOtpForm">
|
|
12
|
+
<div class="pull-left" id="heading">
|
|
13
|
+
{{ constants.verifyAndSetNewPasswordheading }}
|
|
14
|
+
</div>
|
|
15
|
+
<p>{{ authService.verifyAndSetNewPasswordMessage }}</p>
|
|
16
|
+
|
|
17
|
+
<div id="alert-div" *ngIf="authService.verifyAndSetNewPasswordErrorMessage">
|
|
18
|
+
<div id="icon-div">
|
|
19
|
+
<span class="material-icons">report</span>
|
|
20
|
+
</div>
|
|
21
|
+
<p id="display-block-msg">{{ authService.verifyAndSetNewPasswordErrorMessage }}</p>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<input
|
|
25
|
+
type="text"
|
|
26
|
+
tabindex="1"
|
|
27
|
+
formControlName="otp"
|
|
28
|
+
[placeholder]="constants.enterOtp"
|
|
29
|
+
autocomplete="new-field-name"
|
|
30
|
+
[ngClass]="{ 'input-invalid': authService.verifyAndSetNewPasswordErrorMessage }"
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<anna-cognito-lib-password-matching
|
|
34
|
+
(passwordChange)="onPasswordChange($event)"
|
|
35
|
+
(confirmPasswordChange)="onConfirmPasswordChange($event)"
|
|
36
|
+
[passwordNotMatching]="passwordNotMatching"
|
|
37
|
+
>
|
|
38
|
+
</anna-cognito-lib-password-matching>
|
|
39
|
+
<button
|
|
40
|
+
tabindex="4"
|
|
41
|
+
type="submit"
|
|
42
|
+
class="login-btn"
|
|
43
|
+
[disabled]="authService.sessionLocked || !isFormValid()"
|
|
44
|
+
(click)="onVerifyOtpSettingNewPassword()"
|
|
45
|
+
>
|
|
46
|
+
{{ authService.verifyAndSetNewPasswordButton }}
|
|
47
|
+
</button>
|
|
48
|
+
</form>
|
|
49
|
+
</article>
|
|
50
|
+
<footer>
|
|
51
|
+
Powered by <span> <strong>SureWaves</strong> </span>
|
|
52
|
+
</footer>
|
|
53
|
+
</section>
|
|
54
|
+
</div>
|
package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.scss
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import "../../scss/loginTemplate", "../../scss/fonts";
|
|
2
|
+
|
|
3
|
+
.main-height {
|
|
4
|
+
height: 105vh;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
section {
|
|
8
|
+
top: 52%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
p {
|
|
12
|
+
color: $charcoal;
|
|
13
|
+
@include fonts(Roboto, 1rem, normal, normal, normal, normal, normal);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
input[type="text"] {
|
|
17
|
+
margin-bottom: 24px;
|
|
18
|
+
&:focus {
|
|
19
|
+
box-shadow: none;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.back-btn {
|
|
24
|
+
width: 27px;
|
|
25
|
+
height: 27px;
|
|
26
|
+
top: -27px;
|
|
27
|
+
left: -15px;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
position: relative;
|
|
30
|
+
color: #268bff;
|
|
31
|
+
float: left;
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
border: 1px solid #268bff;
|
|
34
|
+
background-color: #f4f4f4;
|
|
35
|
+
& i {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0.1875rem;
|
|
38
|
+
left: 0.25rem;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.spec.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { VerifyAndSetNewPasswordComponent } from './verify-and-set-new-password.component';
|
|
4
|
+
|
|
5
|
+
describe('VerifyAndSetNewPasswordComponent', () => {
|
|
6
|
+
let component: VerifyAndSetNewPasswordComponent;
|
|
7
|
+
let fixture: ComponentFixture<VerifyAndSetNewPasswordComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ VerifyAndSetNewPasswordComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(VerifyAndSetNewPasswordComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Component, Inject, OnInit } from "@angular/core";
|
|
2
|
+
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
|
3
|
+
import { Router } from "@angular/router";
|
|
4
|
+
import { AnnaLibAuthService } from "../../services/auth.service";
|
|
5
|
+
import { LoginConstant } from "../../constants/loginConstant";
|
|
6
|
+
type passwordType = { value: string | null, status: string | null };
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'anna-cognito-lib-verify-and-set-new-password',
|
|
10
|
+
templateUrl: './verify-and-set-new-password.component.html',
|
|
11
|
+
styleUrls: ['./verify-and-set-new-password.component.scss']
|
|
12
|
+
})
|
|
13
|
+
export class VerifyAndSetNewPasswordComponent implements OnInit {
|
|
14
|
+
verifyOtpForm: FormGroup;
|
|
15
|
+
passwordNotMatching = false;
|
|
16
|
+
constants: typeof LoginConstant;
|
|
17
|
+
password: passwordType = { value: null, status: null };
|
|
18
|
+
confirmPassword: passwordType = { value: null, status: null };
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
public authService: AnnaLibAuthService,
|
|
22
|
+
private fb: FormBuilder,
|
|
23
|
+
private router: Router
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
ngOnInit() {
|
|
27
|
+
this.constants = LoginConstant;
|
|
28
|
+
this.authService.verifyAndSetNewPasswordButton = LoginConstant.setNewPasswordButton;
|
|
29
|
+
this.onIntialiseForm();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onIntialiseForm() {
|
|
33
|
+
this.verifyOtpForm = this.fb.group({
|
|
34
|
+
otp: [null, [Validators.required]],
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
isFormValid() {
|
|
39
|
+
if (
|
|
40
|
+
this.password.status === "VALID" &&
|
|
41
|
+
this.confirmPassword.status === "VALID" &&
|
|
42
|
+
this.verifyOtpForm.controls['otp'].valid
|
|
43
|
+
) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onPasswordChange($event: passwordType) {
|
|
50
|
+
this.password = $event;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onConfirmPasswordChange($event: passwordType) {
|
|
54
|
+
this.confirmPassword = $event;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onVerifyOtpSettingNewPassword() {
|
|
58
|
+
if (this.password.value != this.confirmPassword.value) {
|
|
59
|
+
this.passwordNotMatching = true;
|
|
60
|
+
} else {
|
|
61
|
+
this.passwordNotMatching = false;
|
|
62
|
+
if (this.authService.verifyAndSetNewPasswordButton === LoginConstant.regenerateOtp) {
|
|
63
|
+
this.router.navigate([LoginConstant.forgortPasswordPageUrl]);
|
|
64
|
+
} else {
|
|
65
|
+
this.password.value && this.authService.verifyCode(this.verifyOtpForm.controls['otp'].value, this.password.value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/** Token to inject the acl service */
|
|
4
|
+
export const ACL_SERVICE_TOKEN:
|
|
5
|
+
InjectionToken<IAclService> =
|
|
6
|
+
new InjectionToken<IAclService>('ACL service token');
|
|
7
|
+
|
|
8
|
+
export interface IAclService {
|
|
9
|
+
urlToCognitoPrivilegeMap: {[key: string]: string};
|
|
10
|
+
DAILY_REVISION_REPORT_WRITE: string;
|
|
11
|
+
LUR_SETTINGS_WRITE: string;
|
|
12
|
+
MANAGE_BUSINESS_RULES_WRITE: string;
|
|
13
|
+
MANAGE_USERS_WRITE: string;
|
|
14
|
+
ORDER_BIZ_RULES_WRITE: string;
|
|
15
|
+
ORDER_REVISIONS_WRITE: string;
|
|
16
|
+
ORDER_SPOTS_REPORT_WRITE: string;
|
|
17
|
+
RATE_CARD_WRITE: string;
|
|
18
|
+
STATION_SYSTEM_SETTINGS_WRITE: string;
|
|
19
|
+
POLITICAL_WINDOW_WRITE: string;
|
|
20
|
+
|
|
21
|
+
isUserAuthoriseToAcessManageUser(): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
/** Token to inject the auth service */
|
|
5
|
+
export const AUTH_SERVICE_TOKEN:
|
|
6
|
+
InjectionToken<IAuthService> =
|
|
7
|
+
new InjectionToken<IAuthService>('Auth service token');
|
|
8
|
+
|
|
9
|
+
export interface IAuthService {
|
|
10
|
+
isLoggingIn: boolean;
|
|
11
|
+
onSuccessfulAuthenticatingUser(result: any): void;
|
|
12
|
+
isUsernameAvailable(username: string): Observable<any>;
|
|
13
|
+
navigateBasedOnUserRole(loginUserData: any): void;
|
|
14
|
+
getPublicIp(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class LoginConstant {
|
|
2
|
+
// Login page
|
|
3
|
+
static readonly enterEmail = "Enter your username";
|
|
4
|
+
static readonly password = "Password";
|
|
5
|
+
static readonly confirmPassword = "Confirm Password";
|
|
6
|
+
static readonly login = "Login";
|
|
7
|
+
static readonly otp = "OTP";
|
|
8
|
+
static readonly forgotPassword = "Forgot " + LoginConstant.password.toLowerCase() + "?";
|
|
9
|
+
|
|
10
|
+
// set new password
|
|
11
|
+
static readonly setNewPasswordHeading = "Set new " + LoginConstant.password.toLowerCase();
|
|
12
|
+
static readonly setNewPasswordButton = "Set and " + LoginConstant.login.toLowerCase() + " again";
|
|
13
|
+
static readonly passwordMustContain = "The password must contain:";
|
|
14
|
+
static readonly minimumCharacter = "Minimum 8 characters";
|
|
15
|
+
static readonly oneUppercase = "1 Uppercase";
|
|
16
|
+
static readonly oneLowercase = "1 Lowercase";
|
|
17
|
+
static readonly oneNumber = "1 Numerical";
|
|
18
|
+
static readonly specialCharacter = "1 Special character";
|
|
19
|
+
static readonly passwordNotMatching = "The passwords do not match. Please try again.";
|
|
20
|
+
static readonly userNamePasswordIncorrect = "Incorrect username or password";
|
|
21
|
+
static readonly userNotFound = "No registered user found";
|
|
22
|
+
static readonly loginAgain = LoginConstant.login + " again";
|
|
23
|
+
|
|
24
|
+
// verify OTP & set new password
|
|
25
|
+
static readonly verifyAndSetNewPasswordheading = "Enter " + LoginConstant.otp + " & set new password";
|
|
26
|
+
static readonly verifyAndSetNewPasswordMessage = "An " + LoginConstant.otp + " has been succesfully emailed to ";
|
|
27
|
+
static readonly pleaseEnterItBelow = ". Please enter it below.";
|
|
28
|
+
static readonly regenerateOtp = "Regenerate " + LoginConstant.otp;
|
|
29
|
+
static readonly enterOtp = "Enter " + LoginConstant.otp;
|
|
30
|
+
static readonly submit = "Submit";
|
|
31
|
+
static readonly attempt = "Attempt";
|
|
32
|
+
static readonly attemptLimitExceeded =
|
|
33
|
+
"You have exceeded the maximum number of allowed attempts. Please try again after 15 minutes.";
|
|
34
|
+
static readonly attemptMessage = " of 5. The OTP entered is incorrect. Please try again with the right one.";
|
|
35
|
+
static readonly sessionExpired = "The session has expired. Please try again.";
|
|
36
|
+
|
|
37
|
+
// forgot password
|
|
38
|
+
static readonly forgotPasswordHeading = "Forgot your password?";
|
|
39
|
+
static readonly forgotPasswordMessage = "Please enter your username.";
|
|
40
|
+
static readonly forgotPasswordButton = "Get " + LoginConstant.otp;
|
|
41
|
+
static readonly apiFailErrorMessage = "Unable to connect to server right now. Please try after some time.";
|
|
42
|
+
|
|
43
|
+
//url
|
|
44
|
+
static readonly setNewPasswordUrl = "/set-new-password";
|
|
45
|
+
static readonly forgortPasswordPageUrl = "/forgot-password";
|
|
46
|
+
static readonly verifyAndSetNewPasswordUrl = "/verify-and-set-new-password";
|
|
47
|
+
static readonly loginPageUrl = "/login";
|
|
48
|
+
static readonly homePageUrl = "/home";
|
|
49
|
+
static readonly stationSettingUrl = "/station-settings";
|
|
50
|
+
}
|
package/{lib/directives/spinner-button/index.d.ts → src/lib/directives/spinner-button/index.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Component } from "@angular/core";
|
|
2
|
+
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
3
|
+
import { SpinnerButtonDirective } from "./spinner-button.directive";
|
|
4
|
+
@Component({
|
|
5
|
+
template: `<button
|
|
6
|
+
class="my-btn"
|
|
7
|
+
[appSpinnerButton]="loading"
|
|
8
|
+
[spinnerButtonText]="'Button text'"
|
|
9
|
+
(click)="startLoading()"
|
|
10
|
+
></button>`,
|
|
11
|
+
})
|
|
12
|
+
class DummyComponentForTestingSpinnerDirective {
|
|
13
|
+
loading = false;
|
|
14
|
+
startLoading() {
|
|
15
|
+
this.loading = true;
|
|
16
|
+
// to simulate async API call
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
this.loading = false;
|
|
19
|
+
}, 100);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fdescribe("SpinnerButtonDirective", () => {
|
|
24
|
+
let component: DummyComponentForTestingSpinnerDirective;
|
|
25
|
+
let fixture: ComponentFixture<DummyComponentForTestingSpinnerDirective>;
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
TestBed.configureTestingModule({
|
|
29
|
+
declarations: [SpinnerButtonDirective, DummyComponentForTestingSpinnerDirective],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
fixture = TestBed.createComponent(DummyComponentForTestingSpinnerDirective);
|
|
33
|
+
component = fixture.componentInstance;
|
|
34
|
+
fixture.detectChanges();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("0. [ Passed an component instance ] - should create component ", () => {
|
|
38
|
+
expect(component).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Directive, ElementRef, Input, Renderer2, SimpleChanges, OnChanges, OnInit } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: "[anna-cognito-lib-SpinnerButton]",
|
|
5
|
+
})
|
|
6
|
+
export class SpinnerButtonDirective implements OnInit, OnChanges {
|
|
7
|
+
@Input("anna-cognito-lib-SpinnerButton") loading: boolean;
|
|
8
|
+
@Input("spinnerButtonText") spinnerButtonText: string;
|
|
9
|
+
child: HTMLDivElement;
|
|
10
|
+
button: any;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
private el: ElementRef,
|
|
14
|
+
private renderer: Renderer2) {
|
|
15
|
+
this.button = this.el.nativeElement;
|
|
16
|
+
this.child = document.createElement("div");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ngOnInit() {}
|
|
20
|
+
|
|
21
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
22
|
+
if (changes['spinnerButtonText'] && changes['spinnerButtonText'].currentValue) {
|
|
23
|
+
this.button.innerHTML = this.spinnerButtonText;
|
|
24
|
+
}
|
|
25
|
+
if (changes['loading'] && changes['loading'].currentValue) {
|
|
26
|
+
this.button.innerHTML = "";
|
|
27
|
+
this.button.setAttribute("disabled", "true");
|
|
28
|
+
this.child.classList.add("spinner-for-button-directive");
|
|
29
|
+
this.renderer.appendChild(this.button, this.child);
|
|
30
|
+
} else {
|
|
31
|
+
this.child.classList.remove("spinner-for-button-directive");
|
|
32
|
+
this.button.removeAttribute("disabled");
|
|
33
|
+
this.button.innerHTML = this.spinnerButtonText;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class AuthenticationData {
|
|
2
|
+
Username: string;
|
|
3
|
+
Password: string;
|
|
4
|
+
constructor(Username: string, Password: string) {
|
|
5
|
+
this.Username = Username;
|
|
6
|
+
this.Password = Password;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class UserPoolInformation {
|
|
11
|
+
UserPoolId: string;
|
|
12
|
+
ClientId: string;
|
|
13
|
+
constructor(UserPoolId: string, ClientId: string) {
|
|
14
|
+
this.UserPoolId = UserPoolId;
|
|
15
|
+
this.ClientId = ClientId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class UsernameInfo {
|
|
20
|
+
isUsernameAvailable: boolean;
|
|
21
|
+
constructor(object: { isUsernameAvailable: boolean }) {
|
|
22
|
+
this.isUsernameAvailable = object.isUsernameAvailable;
|
|
23
|
+
}
|
|
24
|
+
}
|