@annalib/anna-cognito-lib 0.2.1 → 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.
Files changed (82) hide show
  1. package/.browserslistrc +16 -0
  2. package/README.md +25 -31
  3. package/karma.conf.js +44 -0
  4. package/ng-package.json +7 -0
  5. package/package.json +14 -37
  6. package/src/assets/.gitkeep +0 -0
  7. package/src/assets/images/Anna-Logo.png +0 -0
  8. package/src/lib/anna-cognito-lib.module.ts +51 -0
  9. package/src/lib/components/forgot-password/forgot-password.component.html +44 -0
  10. package/src/lib/components/forgot-password/forgot-password.component.scss +22 -0
  11. package/src/lib/components/forgot-password/forgot-password.component.spec.ts +25 -0
  12. package/src/lib/components/forgot-password/forgot-password.component.ts +75 -0
  13. package/src/lib/components/login/login.component.html +45 -0
  14. package/src/lib/components/login/login.component.scss +10 -0
  15. package/src/lib/components/login/login.component.spec.ts +25 -0
  16. package/src/lib/components/login/login.component.ts +47 -0
  17. package/src/lib/components/password-matching/password-matching.component.html +84 -0
  18. package/src/lib/components/password-matching/password-matching.component.scss +83 -0
  19. package/src/lib/components/password-matching/password-matching.component.spec.ts +25 -0
  20. package/src/lib/components/password-matching/password-matching.component.ts +92 -0
  21. package/src/lib/components/set-new-password/set-new-password.component.html +31 -0
  22. package/src/lib/components/set-new-password/set-new-password.component.scss +1 -0
  23. package/src/lib/components/set-new-password/set-new-password.component.spec.ts +25 -0
  24. package/src/lib/components/set-new-password/set-new-password.component.ts +54 -0
  25. package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.html +54 -0
  26. package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.scss +40 -0
  27. package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.spec.ts +25 -0
  28. package/src/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.ts +70 -0
  29. package/src/lib/config/acl-service.token.ts +22 -0
  30. package/src/lib/config/auth-service.token.ts +15 -0
  31. package/src/lib/config/library.config.ts +8 -0
  32. package/src/lib/constants/loginConstant.ts +50 -0
  33. package/{lib/directives/spinner-button/index.d.ts → src/lib/directives/spinner-button/index.ts} +0 -0
  34. package/src/lib/directives/spinner-button/spinner-button.directive.spec.ts +40 -0
  35. package/src/lib/directives/spinner-button/spinner-button.directive.ts +36 -0
  36. package/src/lib/models/auth.model.ts +24 -0
  37. package/src/lib/scss/_colors.scss +107 -0
  38. package/src/lib/scss/_fonts.scss +86 -0
  39. package/src/lib/scss/_loginTemplate.scss +164 -0
  40. package/src/lib/services/acl.service.ts +24 -0
  41. package/src/lib/services/auth.service.ts +243 -0
  42. package/{public-api.d.ts → src/public-api.ts} +14 -0
  43. package/src/test.ts +27 -0
  44. package/tsconfig.lib.json +18 -0
  45. package/tsconfig.lib.prod.json +10 -0
  46. package/tsconfig.spec.json +17 -0
  47. package/annalib-anna-cognito-lib.d.ts +0 -5
  48. package/esm2020/annalib-anna-cognito-lib.mjs +0 -5
  49. package/esm2020/lib/anna-cognito-lib.module.mjs +0 -74
  50. package/esm2020/lib/components/forgot-password/forgot-password.component.mjs +0 -69
  51. package/esm2020/lib/components/login/login.component.mjs +0 -44
  52. package/esm2020/lib/components/password-matching/password-matching.component.mjs +0 -90
  53. package/esm2020/lib/components/set-new-password/set-new-password.component.mjs +0 -55
  54. package/esm2020/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.mjs +0 -66
  55. package/esm2020/lib/config/acl-service.token.mjs +0 -4
  56. package/esm2020/lib/config/auth-service.token.mjs +0 -4
  57. package/esm2020/lib/config/library.config.mjs +0 -6
  58. package/esm2020/lib/constants/loginConstant.mjs +0 -46
  59. package/esm2020/lib/directives/spinner-button/index.mjs +0 -2
  60. package/esm2020/lib/directives/spinner-button/spinner-button.directive.mjs +0 -42
  61. package/esm2020/lib/models/auth.model.mjs +0 -18
  62. package/esm2020/lib/services/acl.service.mjs +0 -30
  63. package/esm2020/lib/services/auth.service.mjs +0 -218
  64. package/esm2020/public-api.mjs +0 -21
  65. package/fesm2015/annalib-anna-cognito-lib.mjs +0 -703
  66. package/fesm2015/annalib-anna-cognito-lib.mjs.map +0 -1
  67. package/fesm2020/annalib-anna-cognito-lib.mjs +0 -697
  68. package/fesm2020/annalib-anna-cognito-lib.mjs.map +0 -1
  69. package/lib/anna-cognito-lib.module.d.ts +0 -18
  70. package/lib/components/forgot-password/forgot-password.component.d.ts +0 -31
  71. package/lib/components/login/login.component.d.ts +0 -19
  72. package/lib/components/password-matching/password-matching.component.d.ts +0 -22
  73. package/lib/components/set-new-password/set-new-password.component.d.ts +0 -26
  74. package/lib/components/verify-and-set-new-password/verify-and-set-new-password.component.d.ts +0 -30
  75. package/lib/config/acl-service.token.d.ts +0 -19
  76. package/lib/config/auth-service.token.d.ts +0 -11
  77. package/lib/config/library.config.d.ts +0 -7
  78. package/lib/constants/loginConstant.d.ts +0 -40
  79. package/lib/directives/spinner-button/spinner-button.directive.d.ts +0 -15
  80. package/lib/models/auth.model.d.ts +0 -16
  81. package/lib/services/acl.service.d.ts +0 -12
  82. package/lib/services/auth.service.d.ts +0 -53
@@ -0,0 +1,16 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # For the full list of supported browsers by the Angular framework, please see:
6
+ # https://angular.io/guide/browser-support
7
+
8
+ # You can see what browsers were selected by your queries by running:
9
+ # npx browserslist
10
+
11
+ last 1 Chrome version
12
+ last 1 Firefox version
13
+ last 2 Edge major versions
14
+ last 2 Safari major versions
15
+ last 2 iOS major versions
16
+ Firefox ESR
package/README.md CHANGED
@@ -1,48 +1,42 @@
1
1
  # AnnaCognitoLib
2
2
  ## How to use the library in the consuming project ?
3
- 1. Install the package from npm - `npm install @annalib/anna-cognito-lib` (if not working use with --force flag).
4
3
 
5
- 2. After installing the Library, you need to install it's peer dependancies.
6
- 2. 1. You can find the peer-dependecies in package.json file of library. Install all the peer depedencies with respective version number mentioned. this is important step otherwise lbrary will throw error.
7
- 2. ex: `npm install ngx-toastr@13.2.1`
4
+ 1. Install the package from npm
5
+ `npm install @annalib/anna-cognito-lib` (if not working use with --force flag).
6
+ 2. After installing the Library, you need to install it's peer dependancies. You can find the peer-dependecies in package.json file of library. Install all the peer depedencies with respective version number mentioned. this is important step otherwise library will throw error.
7
+ ex: ```npm install ngx-toastr@13.2.1```
8
+ 3. Also make sure to Install the Roboto font locally in assets folder of your consuming project.
8
9
 
9
- 3. Adding Configuration
10
- 3. 1. import the `AnnaCognitoLibModule` module and pass the configuration to root `AnnaCognitoLibModule.forRoot(AnnaCognitoLibraryConfig)`
11
- 2. configuration const should be:
12
- <kbd>
13
- const AnnaCognitoLibraryConfig = {
10
+ If using the library locally (library from your system locally not npm),then in angular json file you have to set `preserveSymlinks: true`.
11
+
12
+ ## Adding Configuration
13
+ 1. import the `AnnaCognitoLibModule` module and pass the configuration to root `AnnaCognitoLibModule.forRoot(AnnaCognitoLibraryConfig)`
14
+ 2. configuration const should be:
15
+ ``` const AnnaCognitoLibraryConfig = {
14
16
  cognito : {
15
17
  userPoolId: "",
16
18
  clientId: "",
17
19
  },
18
20
  loginPageLogoImgUrl: ""
19
- }
20
- </kbd>
21
- 3. c. Default loginPageLogoImgUrl is ANNA logo image.
22
- In case you want to add another Logo image, add the logo image file in library's asset folder and provide new loginPageLogoImgUrl.
23
- Note: for better loading of logo image, provide logo image in minified format.
24
-
25
-
26
- 4. Adding new custom function implemetation for any service file.
27
- 4. 1. Background Understanding - when we want to provide custom implemenetation - We write the custom implementation in a service file of consuming project and that is injected in the library. Injection is taken care by library itself. You just need to provide the definition and implementation of new function added.
28
- 2. Ex: let's say we want to add a new function `onSuccessfulAuthenticatingUser() this function is called from library when user is succesfully authenticated and logged in. (Note: this function is already present in lib).
29
- 3. Then In library add the new function declaration `onSuccessfulAuthenticatingUser()` in interface file `IAuthService` of `auth-service.token.ts` file.
30
- 4. In consuming project, for `onSuccessfulAuthenticatingUser()` provide the implementation in the service file say `AuthService` of `auth.service.ts`.
31
- 5. Then In consuming project, app.module.ts file add following in providers array.
32
- `{ provide: AUTH_SERVICE_TOKEN, useExisting: AuthService }`
33
- i.e. your consuming project's existing AuthService will be injected in Library's auth-service file with the help of AUTH_SERVICE_TOKEN.
34
- 6. Now you're good to go!
21
+ } ```
22
+ 3. Keep the logo image in consuming project and provide the path for loginPageLogoImgUrl. ex: "assets/images/Anna-Logo.png"
23
+ Note: for better loading of logo image, provide logo image in minified format.
24
+
25
+
26
+ ## Adding new custom function implemetation for any service file.
27
+ 1. Background Understanding - when we want to provide custom implemenetation - We write the custom implementation in a service file of consuming project and that is injected in the library. Injection is taken care by library itself. You just need to provide the definition and implementation of new function added.
28
+ 2. Ex: let's say we want to add a new function `onSuccessfulAuthenticatingUser() this function is called from library when user is succesfully authenticated and logged in. (Note: this function is already present in lib).
29
+ 3. Then In library add the new function declaration `onSuccessfulAuthenticatingUser()` in interface file `IAuthService` of `auth-service.token.ts` file.
30
+ 4. In consuming project, for `onSuccessfulAuthenticatingUser()` provide the implementation in the service file say `AuthService` of `auth.service.ts`.
31
+ 5. Then In consuming project, app.module.ts file add following in providers array.
32
+ `{ provide: AUTH_SERVICE_TOKEN, useExisting: AuthService }`
33
+ i.e. your consuming project's existing AuthService will be injected in Library's auth-service file with the help of AUTH_SERVICE_TOKEN.
34
+ 6. Now you're good to go!
35
35
 
36
- 5. Also make sure to Install the Roboto font locally in assets folder of your consuming project.
37
-
38
- If using the library locally (library from your system locally not npm),then in angular json file you have to set `preserveSymlinks: true`.
39
-
40
36
 
41
37
  ## List of function implementation we need to provide in consuming project.
42
38
  1. `onSuccessfulAuthenticatingUser()` - provide the implementation of what happens when user is succefully logged in. (any API call or routing you need to provide).
43
-
44
39
  2. `isUsernameAvailable()` - in thie implementation call an backend API to find out if username is already present in Database or not. format of response should be `{"isUsernameAvailable":true}`. This is used in forgot-password page before calling forgot-password cognito sdk call, we need to check thorough backend db if the username is actually available.
45
-
46
40
  3. `isLoggingIn` - set this variable to false. this will stop the spinner on top on button.
47
41
  use case: after successful login i.e. when we are done with all API call we need to call post succesfull calling or when we have routed to home page.
48
42
 
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/anna-cognito-lib'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/anna-cognito-lib",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,37 +1,14 @@
1
- {
2
- "name": "@annalib/anna-cognito-lib",
3
- "version": "0.2.1",
4
- "peerDependencies": {
5
- "@angular/common": "^13.2.0",
6
- "@angular/core": "^13.2.0",
7
- "@mdi/font": "^5.1.45",
8
- "@ng-bootstrap/ng-bootstrap": "^9.0.1",
9
- "@types/node": "^12.11.1",
10
- "amazon-cognito-identity-js": "^4.5.3",
11
- "bootstrap": "^4.3.1",
12
- "ngx-toastr": "^13.2.1"
13
- },
14
- "module": "fesm2015/annalib-anna-cognito-lib.mjs",
15
- "es2020": "fesm2020/annalib-anna-cognito-lib.mjs",
16
- "esm2020": "esm2020/annalib-anna-cognito-lib.mjs",
17
- "fesm2020": "fesm2020/annalib-anna-cognito-lib.mjs",
18
- "fesm2015": "fesm2015/annalib-anna-cognito-lib.mjs",
19
- "typings": "annalib-anna-cognito-lib.d.ts",
20
- "exports": {
21
- "./package.json": {
22
- "default": "./package.json"
23
- },
24
- ".": {
25
- "types": "./annalib-anna-cognito-lib.d.ts",
26
- "esm2020": "./esm2020/annalib-anna-cognito-lib.mjs",
27
- "es2020": "./fesm2020/annalib-anna-cognito-lib.mjs",
28
- "es2015": "./fesm2015/annalib-anna-cognito-lib.mjs",
29
- "node": "./fesm2015/annalib-anna-cognito-lib.mjs",
30
- "default": "./fesm2020/annalib-anna-cognito-lib.mjs"
31
- }
32
- },
33
- "sideEffects": false,
34
- "dependencies": {
35
- "tslib": "^2.3.0"
36
- }
37
- }
1
+ {
2
+ "name": "@annalib/anna-cognito-lib",
3
+ "version": "0.2.4",
4
+ "peerDependencies": {
5
+ "@angular/common": "^13.2.0",
6
+ "@angular/core": "^13.2.0",
7
+ "@mdi/font": "^5.1.45",
8
+ "@ng-bootstrap/ng-bootstrap": "^9.0.1",
9
+ "@types/node": "^12.11.1",
10
+ "amazon-cognito-identity-js": "^4.5.3",
11
+ "bootstrap": "^4.3.1",
12
+ "ngx-toastr": "^13.2.1"
13
+ }
14
+ }
File without changes
Binary file
@@ -0,0 +1,51 @@
1
+ import { ModuleWithProviders, NgModule } from '@angular/core';
2
+ import { LoginComponent } from './components/login/login.component';
3
+ import { SpinnerButtonDirective } from './directives/spinner-button';
4
+ import { LibraryConfig } from './config/library.config';
5
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
6
+ import { RouterModule } from '@angular/router';
7
+ import { CommonModule } from '@angular/common';
8
+ import { SetNewPasswordComponent } from './components/set-new-password/set-new-password.component';
9
+ import { PasswordMatchingComponent } from './components/password-matching/password-matching.component';
10
+ import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component';
11
+ import { VerifyAndSetNewPasswordComponent } from './components/verify-and-set-new-password/verify-and-set-new-password.component';
12
+
13
+
14
+
15
+ @NgModule({
16
+ declarations: [
17
+ LoginComponent,
18
+ SetNewPasswordComponent,
19
+ PasswordMatchingComponent,
20
+ ForgotPasswordComponent,
21
+ VerifyAndSetNewPasswordComponent,
22
+ SpinnerButtonDirective,
23
+ ],
24
+ imports: [
25
+ FormsModule,
26
+ ReactiveFormsModule,
27
+ RouterModule,
28
+ CommonModule
29
+ ],
30
+ exports: [
31
+ LoginComponent,
32
+ SetNewPasswordComponent,
33
+ PasswordMatchingComponent,
34
+ ForgotPasswordComponent,
35
+ VerifyAndSetNewPasswordComponent,
36
+ SpinnerButtonDirective
37
+ ]
38
+ })
39
+ export class AnnaCognitoLibModule {
40
+ public static forRoot(configuration: LibraryConfig): ModuleWithProviders<AnnaCognitoLibModule> {
41
+ return {
42
+ ngModule: AnnaCognitoLibModule,
43
+ providers: [
44
+ {
45
+ provide: LibraryConfig,
46
+ useValue: configuration
47
+ }
48
+ ]
49
+ };
50
+ }
51
+ }
@@ -0,0 +1,44 @@
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 [formGroup]="verifyRegisteredEmail">
8
+ <div id="heading">
9
+ {{ constants.forgotPasswordHeading }}
10
+ </div>
11
+ <p>
12
+ {{ constants.forgotPasswordMessage }}
13
+ </p>
14
+ <div id="alert-div" *ngIf="errorMessage">
15
+ <span class="material-icons">report</span>
16
+ <p id="alert-msg">{{ errorMessage }}</p>
17
+ </div>
18
+
19
+ <input
20
+ type="text"
21
+ tabindex="1"
22
+ formControlName="email"
23
+ [placeholder]="constants.enterEmail"
24
+ [ngClass]="{
25
+ 'input-invalid': verifyRegisteredEmail.get('email')?.dirty && verifyRegisteredEmail.get('email')?.errors
26
+ }"
27
+ />
28
+
29
+ <button
30
+ tabindex="2"
31
+ type="submit"
32
+ class="login-btn"
33
+ [disabled]="!isFormValid()"
34
+ (click)="onVerifyRegisteredEmail()"
35
+ >
36
+ {{ constants.forgotPasswordButton }}
37
+ </button>
38
+ </form>
39
+ </article>
40
+ <footer>
41
+ Powered by <span> <strong> SureWaves</strong></span>
42
+ </footer>
43
+ </section>
44
+ </div>
@@ -0,0 +1,22 @@
1
+ @import "../../scss/loginTemplate", "../../scss/fonts", "../../scss/colors";
2
+ p {
3
+ color: $charcoal;
4
+ @include fonts(Roboto, 1rem, normal, normal, normal, normal, normal);
5
+ }
6
+
7
+ input[type="text"] {
8
+ margin-bottom: 16px;
9
+ &:focus {
10
+ box-shadow: none;
11
+ }
12
+ }
13
+
14
+ .back-btn {
15
+ font-size: 27px;
16
+ position: relative;
17
+ color: #268bff;
18
+ float: left;
19
+ top: -30px;
20
+ left: -15px;
21
+ font-weight: normal !important;
22
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { ForgotPasswordComponent } from './forgot-password.component';
4
+
5
+ describe('ForgotPasswordComponent', () => {
6
+ let component: ForgotPasswordComponent;
7
+ let fixture: ComponentFixture<ForgotPasswordComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ ForgotPasswordComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(ForgotPasswordComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,75 @@
1
+ // Angular import statements
2
+ import { Component, OnInit } from "@angular/core";
3
+ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
4
+
5
+ // Third party import statements
6
+ import { ToastrService } from "ngx-toastr";
7
+
8
+ // User defined import statements
9
+ import { UsernameInfo } from "../../models/auth.model";
10
+ import { AnnaLibAuthService } from "../../services/auth.service";
11
+ import { LoginConstant } from "../../constants/loginConstant";
12
+
13
+ @Component({
14
+ selector: 'anna-cognito-lib-forgot-password',
15
+ templateUrl: './forgot-password.component.html',
16
+ styleUrls: ['./forgot-password.component.scss']
17
+ })
18
+ export class ForgotPasswordComponent implements OnInit {
19
+ errorMessage: string;
20
+ verifyRegisteredEmail: FormGroup;
21
+ passwordNotMatching = false;
22
+ constants: typeof LoginConstant;
23
+ password = { value: null, status: null };
24
+ confirmPassword = { value: null, status: null };
25
+
26
+ constructor(
27
+ private authService: AnnaLibAuthService,
28
+ private fb: FormBuilder,
29
+ private toastr: ToastrService
30
+ ) {}
31
+
32
+ ngOnInit() {
33
+ this.constants = LoginConstant;
34
+ this.onIntialiseForm();
35
+ if (this.authService.userName) {
36
+ this.onUpdateForm();
37
+ }
38
+ }
39
+
40
+ onIntialiseForm() {
41
+ this.verifyRegisteredEmail = this.fb.group({
42
+ email: [null, [Validators.required]],
43
+ });
44
+ }
45
+
46
+ onUpdateForm() {
47
+ this.verifyRegisteredEmail.patchValue({
48
+ email: this.authService.userName,
49
+ });
50
+ }
51
+
52
+ isFormValid() {
53
+ return this.verifyRegisteredEmail.valid;
54
+ }
55
+
56
+ onVerifyRegisteredEmail() {
57
+ let username = this.verifyRegisteredEmail.controls['email'].value;
58
+ this.authService.consumingProjectAuthService.isUsernameAvailable(username)
59
+ .subscribe(
60
+ {
61
+ next: (response) => {
62
+ let res = new UsernameInfo(response);
63
+ if (!res.isUsernameAvailable) {
64
+ this.authService.onForgotPasswordGenerateOTP(username);
65
+ } else {
66
+ this.errorMessage = this.constants.userNotFound;
67
+ }
68
+ },
69
+ error: any => {
70
+ this.toastr.error(LoginConstant.apiFailErrorMessage);
71
+ }
72
+ }
73
+ );
74
+ }
75
+ }
@@ -0,0 +1,45 @@
1
+ <div class="main">
2
+ <!-- Load login page when all constant variable are intiated otherwise it will show a glitch. that's why ngIf check of constants.forgotPassword -->
3
+ <section *ngIf="constants.forgotPassword">
4
+ <header>
5
+ <img [src]="libraryConfig.loginPageLogoImgUrl" loading="eager" alt="Anna Logo" />
6
+ </header>
7
+ <article>
8
+ <form [formGroup]="loginForm" (ngSubmit)="OnLogin()">
9
+ <div id="alert-div" *ngIf="authService.loginErrorMessage">
10
+ <span class="material-icons">report</span>
11
+ <p>{{ authService.loginErrorMessage }}</p>
12
+ </div>
13
+
14
+ <input
15
+ type="text"
16
+ tabindex="1"
17
+ formControlName="username"
18
+ [ngClass]="{ 'input-invalid': authService.loginErrorMessage }"
19
+ [placeholder]="constants.enterEmail"
20
+ autocomplete="username"
21
+ autofocus
22
+ />
23
+
24
+ <input
25
+ type="password"
26
+ tabindex="2"
27
+ formControlName="password"
28
+ [ngClass]="{ 'input-invalid': authService.loginErrorMessage }"
29
+ [placeholder]="constants.password"
30
+ autocomplete="current-password"
31
+ autofocus
32
+ />
33
+
34
+ <a tabindex="4" [routerLink]="constants.forgortPasswordPageUrl">{{ constants.forgotPassword }}</a>
35
+ <button
36
+ tabindex="3"
37
+ class="login-btn"
38
+ [anna-cognito-lib-SpinnerButton]="authService.consumingProjectAuthService.isLoggingIn"
39
+ [spinnerButtonText]="constants.login"
40
+ ></button>
41
+ </form>
42
+ </article>
43
+ <footer>Powered by <span>SureWaves</span></footer>
44
+ </section>
45
+ </div>
@@ -0,0 +1,10 @@
1
+ @import "../../scss/loginTemplate", "../../scss/fonts";
2
+ a {
3
+ float: right;
4
+ color: #268bff;
5
+ @include fonts(Roboto, 0.875rem, normal, normal, normal, normal, normal);
6
+ text-decoration: underline;
7
+ &:hover {
8
+ cursor: pointer;
9
+ }
10
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { LoginComponent } from './login.component';
4
+
5
+ describe('LoginComponent', () => {
6
+ let component: LoginComponent;
7
+ let fixture: ComponentFixture<LoginComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ LoginComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(LoginComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,47 @@
1
+ // Angular import statements
2
+ import { Component, OnInit } from "@angular/core";
3
+ import { FormBuilder, FormGroup } from "@angular/forms";
4
+
5
+ // User defined import statements
6
+ import { LoginConstant } from "../../constants/loginConstant";
7
+ import { AnnaLibAuthService } from '../../services/auth.service';
8
+ import { LibraryConfig } from '../../config/library.config';
9
+
10
+ @Component({
11
+ selector: "anna-cognito-lib-login",
12
+ templateUrl: "./login.component.html",
13
+ styleUrls: ["./login.component.scss"],
14
+ })
15
+ export class LoginComponent implements OnInit {
16
+ loginForm: FormGroup;
17
+ constants: typeof LoginConstant;
18
+ annaLogoUrl: string = "assets/images/Anna-Logo-for-footer-min.png";
19
+ logoUrl: string;
20
+
21
+ constructor(
22
+ public authService: AnnaLibAuthService,
23
+ private fb: FormBuilder,
24
+ public libraryConfig: LibraryConfig
25
+ ) {}
26
+
27
+ ngOnInit() {
28
+ this.constants = LoginConstant;
29
+ this.onIntialiseForm();
30
+ }
31
+
32
+ onIntialiseForm() {
33
+ this.loginForm = this.fb.group({
34
+ username: [null],
35
+ password: [null],
36
+ });
37
+ }
38
+
39
+ OnLogin() {
40
+ this.authService.consumingProjectAuthService.isLoggingIn = true;
41
+ const username = this.loginForm.controls['username'].value;
42
+ const password = this.loginForm.controls['password'].value;
43
+ this.authService.authenticate(username, password);
44
+ }
45
+
46
+
47
+ }
@@ -0,0 +1,84 @@
1
+ <form [formGroup]="passwordForm">
2
+ <div id="alert-div" *ngIf="passwordNotMatching">
3
+ <div id="icon-div">
4
+ <span class="material-icons">report</span>
5
+ </div>
6
+ <p>{{ constants.passwordNotMatching }}</p>
7
+ </div>
8
+ <div class="password-policies">
9
+ <ng-container *ngIf="!passwordForm.get('password')?.dirty">
10
+ <p>
11
+ <b>{{ constants.passwordMustContain }} </b>
12
+ </p>
13
+ <p>{{ constants.minimumCharacter }}</p>
14
+ <p>{{ constants.oneUppercase }}</p>
15
+ <p>{{ constants.oneLowercase }}</p>
16
+ <p>{{ constants.oneNumber }}</p>
17
+ <p>{{ constants.specialCharacter }}</p>
18
+ </ng-container>
19
+
20
+ <ng-container *ngIf="passwordForm.get('password')?.dirty">
21
+ <p>
22
+ <b>{{ constants.passwordMustContain }}</b>
23
+ </p>
24
+
25
+ <div [ngClass]="passwordForm.get('password')?.hasError('minLength') ? 'error-color' : 'success-color'">
26
+ <div id="icon-div-msg">
27
+ <span class="material-icons" *ngIf="passwordForm.get('password')?.hasError('minLength')"> cancel </span>
28
+ <span class="material-icons" *ngIf="!passwordForm.get('password')?.hasError('minLength')"> check_circle </span>
29
+ </div>
30
+ <span class="span-text">{{ constants.minimumCharacter }}</span>
31
+ </div>
32
+
33
+ <div [ngClass]="passwordForm.get('password')?.hasError('uppercase') ? 'error-color' : 'success-color'">
34
+ <div id="icon-div-msg">
35
+ <span class="material-icons" *ngIf="passwordForm.get('password')?.hasError('uppercase')"> cancel </span>
36
+ <span class="material-icons" *ngIf="!passwordForm.get('password')?.hasError('uppercase')"> check_circle </span>
37
+ </div>
38
+ <span class="span-text">{{ constants.oneUppercase }}</span>
39
+ </div>
40
+
41
+ <div [ngClass]="passwordForm.get('password')?.hasError('lowercase') ? 'error-color' : 'success-color'">
42
+ <div id="icon-div-msg">
43
+ <span class="material-icons" *ngIf="passwordForm.get('password')?.hasError('lowercase')"> cancel </span>
44
+ <span class="material-icons" *ngIf="!passwordForm.get('password')?.hasError('lowercase')"> check_circle </span>
45
+ </div>
46
+ <span class="span-text">{{ constants.oneLowercase }}</span>
47
+ </div>
48
+
49
+ <div [ngClass]="passwordForm.get('password')?.hasError('number') ? 'error-color' : 'success-color'">
50
+ <div id="icon-div-msg">
51
+ <span class="material-icons" *ngIf="passwordForm.get('password')?.hasError('number')"> cancel </span>
52
+ <span class="material-icons" *ngIf="!passwordForm.get('password')?.hasError('number')"> check_circle </span>
53
+ </div>
54
+ <span class="span-text">{{ constants.oneNumber }}</span>
55
+ </div>
56
+
57
+ <div [ngClass]="passwordForm.get('password')?.hasError('specialCharacter') ? 'error-color' : 'success-color'">
58
+ <div id="icon-div-msg">
59
+ <span class="material-icons" *ngIf="passwordForm.get('password')?.hasError('specialCharacter')"> cancel </span>
60
+ <span class="material-icons" *ngIf="!passwordForm.get('password')?.hasError('specialCharacter')">
61
+ check_circle
62
+ </span>
63
+ </div>
64
+ <span class="span-text">{{ constants.specialCharacter }}</span>
65
+ </div>
66
+ </ng-container>
67
+ </div>
68
+
69
+ <input
70
+ type="password"
71
+ tabindex="2"
72
+ formControlName="password"
73
+ [placeholder]="constants.password"
74
+ [ngClass]="{ 'input-invalid': passwordNotMatching }"
75
+ />
76
+
77
+ <input
78
+ type="password"
79
+ tabindex="3"
80
+ formControlName="confirmPassword"
81
+ [placeholder]="constants.confirmPassword"
82
+ [ngClass]="{ 'input-invalid': passwordNotMatching }"
83
+ />
84
+ </form>