From ae9243c2b67274310ad4809a012e614769e9b1ec Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Mon, 28 Nov 2022 15:23:27 +0000 Subject: [PATCH] ACA-4611 Committed the backend changes --- lib/core/src/lib/core.module.ts | 3 + .../forgot-password.component.html | 55 ++ .../forgot-password.component.scss | 44 ++ .../forgot-password.component.spec.ts | 23 + .../forgot-password.component.ts | 54 ++ .../forgot-password/forgot-password.module.ts | 33 + lib/core/src/lib/i18n/en.json | 19 + .../lib/login/components/login.component.html | 7 + .../lib/login/components/login.component.ts | 16 +- package-lock.json | 694 +++++++++--------- 10 files changed, 601 insertions(+), 347 deletions(-) create mode 100644 lib/core/src/lib/forgot-password/forgot-password.component.html create mode 100644 lib/core/src/lib/forgot-password/forgot-password.component.scss create mode 100644 lib/core/src/lib/forgot-password/forgot-password.component.spec.ts create mode 100644 lib/core/src/lib/forgot-password/forgot-password.component.ts create mode 100644 lib/core/src/lib/forgot-password/forgot-password.module.ts diff --git a/lib/core/src/lib/core.module.ts b/lib/core/src/lib/core.module.ts index 9df7a05df5..bc87763336 100644 --- a/lib/core/src/lib/core.module.ts +++ b/lib/core/src/lib/core.module.ts @@ -30,6 +30,7 @@ import { DataTableModule } from './datatable/datatable.module'; import { InfoDrawerModule } from './info-drawer/info-drawer.module'; import { LanguageMenuModule } from './language-menu/language-menu.module'; import { LoginModule } from './login/login.module'; +import { ForgotPasswordModule } from './forgot-password/forgot-password.module'; import { PaginationModule } from './pagination/pagination.module'; import { HostSettingsModule } from './settings/host-settings.module'; import { ToolbarModule } from './toolbar/toolbar.module'; @@ -92,6 +93,7 @@ import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; FormBaseModule, CommentsModule, LoginModule, + ForgotPasswordModule, LanguageMenuModule, InfoDrawerModule, DataColumnModule, @@ -134,6 +136,7 @@ import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; FormBaseModule, CommentsModule, LoginModule, + ForgotPasswordModule, LanguageMenuModule, InfoDrawerModule, DataColumnModule, diff --git a/lib/core/src/lib/forgot-password/forgot-password.component.html b/lib/core/src/lib/forgot-password/forgot-password.component.html new file mode 100644 index 0000000000..88eeb36325 --- /dev/null +++ b/lib/core/src/lib/forgot-password/forgot-password.component.html @@ -0,0 +1,55 @@ +
+
+
+
+ {{ 'PASSWORD.RECOVER-PASSWORD' | translate }} +
+
+
+ +
+

{{ 'PASSWORD.MESSAGES.FILLER' | translate }}

+
+ +
+ + + + + {{ 'PASSWORD.MESSAGES.USERNAME-REQUIRED' | translate }} + + +
+ +
+ +
+
+
+
+ + +
+
diff --git a/lib/core/src/lib/forgot-password/forgot-password.component.scss b/lib/core/src/lib/forgot-password/forgot-password.component.scss new file mode 100644 index 0000000000..a280d6165a --- /dev/null +++ b/lib/core/src/lib/forgot-password/forgot-password.component.scss @@ -0,0 +1,44 @@ +.app { + &-dialog { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + height: 50%; + &-body { + flex: 1; + overflow-y: auto; + padding: 0 15px; + } + &-footer { + display: flex; + justify-content: flex-end; + align-self: flex-end; + } + } + &-security-controls { + &-actions { + padding: 15px 10px; + } + &-toggle-description-text { + color: var(--theme-accent-color); + font-weight: bold; + cursor: pointer; + } + &-config-type-image-container { + display: flex; + width: 100%; + flex-direction: row; + justify-content: center; + } + &-config-type-image { + width: 100%; + } + } +} + +.app-recover-password-btn { + background: var(--theme-blue-text-background); + border: 1px solid var(--theme-blue-border-color); + font-size: var(--theme-button-font-size); +} diff --git a/lib/core/src/lib/forgot-password/forgot-password.component.spec.ts b/lib/core/src/lib/forgot-password/forgot-password.component.spec.ts new file mode 100644 index 0000000000..79f223d06b --- /dev/null +++ b/lib/core/src/lib/forgot-password/forgot-password.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ForgotPasswordComponent } from './forgot-password.component'; + +describe('ForgotPasswordComponent', () => { + let component: ForgotPasswordComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ForgotPasswordComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ForgotPasswordComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/lib/core/src/lib/forgot-password/forgot-password.component.ts b/lib/core/src/lib/forgot-password/forgot-password.component.ts new file mode 100644 index 0000000000..21f6ef1c8b --- /dev/null +++ b/lib/core/src/lib/forgot-password/forgot-password.component.ts @@ -0,0 +1,54 @@ +/* + * Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved. + * + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { PeopleApi, ClientBody } from '@alfresco/js-api'; +import { AlfrescoApiService } from '@alfresco/adf-core'; + +@Component({ + selector: 'app-forgot-password', + templateUrl: './forgot-password.component.html', + styleUrls: ['./forgot-password.component.scss'] +}) +export class ForgotPasswordComponent implements OnInit{ + private peopleApi: PeopleApi; + forgotPasswordForm: FormGroup; + isSaveInProgress : boolean = false; + passwordResetStatus : boolean = false; + + constructor( + private apiService: AlfrescoApiService, + private formBuilder: FormBuilder) {} + + ngOnInit(): void { + this.forgotPasswordForm = this.formBuilder.group({ + userName: ['', [Validators.required]] + }) + } + + get peopleApiInstance() { + return ( + this.peopleApi || + (this.peopleApi = new PeopleApi(this.apiService.getInstance())) + ); + } + + sendInstructions() { + this.isSaveInProgress = true; + this.passwordResetStatus = true; + console.log("Sending Email to user ", this.forgotPasswordForm.controls.userName.value); + + this.peopleApiInstance.requestPasswordReset( + this.forgotPasswordForm.controls.userName.value, {'client': 'adw'} as ClientBody); + } + + isButtonDisabled(): boolean { + return this.forgotPasswordForm.invalid || this.isSaveInProgress; + } +} diff --git a/lib/core/src/lib/forgot-password/forgot-password.module.ts b/lib/core/src/lib/forgot-password/forgot-password.module.ts new file mode 100644 index 0000000000..e3eda318ee --- /dev/null +++ b/lib/core/src/lib/forgot-password/forgot-password.module.ts @@ -0,0 +1,33 @@ +/* + * Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved. + * + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { TranslateModule } from '@ngx-translate/core'; +import { MaterialModule } from '../material.module'; +import { ForgotPasswordComponent } from './forgot-password.component'; + +@NgModule({ + imports: [ + RouterModule, + MaterialModule, + FormsModule, + ReactiveFormsModule, + CommonModule, + TranslateModule + ], + declarations: [ + ForgotPasswordComponent + ], + exports: [ + ForgotPasswordComponent + ] +}) +export class ForgotPasswordModule {} diff --git a/lib/core/src/lib/i18n/en.json b/lib/core/src/lib/i18n/en.json index 1b4fdec6c7..52e864cc32 100644 --- a/lib/core/src/lib/i18n/en.json +++ b/lib/core/src/lib/i18n/en.json @@ -309,12 +309,31 @@ "HELP": "NEED HELP?", "REGISTER": "REGISTER" }, + "FORGOT-PASSWORD": { + "FORGOT-PASSWORD": "Forgot Password?" + }, "DIALOG": { "CANCEL": "Cancel", "CHOOSE": "Choose", "LOGIN": "Sign in" } }, + "PASSWORD": { + "RECOVER-PASSWORD": "Recover Password", + "MESSAGES": { + "USERNAME-REQUIRED": "Required", + "FILLER": "Don't worry, happens to the best of us.", + "ENTER-USERNAME": "Enter Username of your account", + "INVALID-USERNAME": "You've entered an invalid Email ID", + "RESET-PASSWORD-EMAIL-SENT": "An email has been sent to your registered Email ID. Please click this link when get it." + }, + "PLACEHOLDERS": { + "USERNAME": "USERNAME" + }, + "BUTTONS": { + "SEND-INSTRUCTIONS": "Send Instructions" + } + }, "ADF-DATATABLE": { "EMPTY": { "HEADER": "This list is empty", diff --git a/lib/core/src/lib/login/components/login.component.html b/lib/core/src/lib/login/components/login.component.html index 18144998b7..39bb274c91 100644 --- a/lib/core/src/lib/login/components/login.component.html +++ b/lib/core/src/lib/login/components/login.component.html @@ -168,6 +168,13 @@ {{ 'LOGIN.LABEL.REMEMBER' | translate }} +