diff --git a/eFormAPI/eFormAPI/Controllers/AccountController.cs b/eFormAPI/eFormAPI/Controllers/AccountController.cs index d1a9c2f49e..a0d04ddda8 100644 --- a/eFormAPI/eFormAPI/Controllers/AccountController.cs +++ b/eFormAPI/eFormAPI/Controllers/AccountController.cs @@ -144,7 +144,7 @@ public async Task ForgotPassword(ForgotPasswordModel model) } var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var link = ConfigurationManager.AppSettings["app:siteLink"]; - link = $"{link}/login/restore-password?userId={user.Id}&code={code}"; + link = $"{link}/restore-password-confirmation?userId={user.Id}&code={code}"; await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here"); return new OperationResult(true); diff --git a/eform-client/src/app/common/services/base.service.ts b/eform-client/src/app/common/services/base.service.ts index d16e5a67c3..0373660290 100644 --- a/eform-client/src/app/common/services/base.service.ts +++ b/eform-client/src/app/common/services/base.service.ts @@ -124,7 +124,7 @@ export class BaseService { private logOutWhenTokenFalse() { localStorage.clear(); - this.router.navigate(['/auth/login']).then(); + this.router.navigate(['/auth']).then(); } diff --git a/eform-client/src/app/modules/auth/auth.module.ts b/eform-client/src/app/modules/auth/auth.module.ts index 032d887c8c..8815c6fb00 100644 --- a/eform-client/src/app/modules/auth/auth.module.ts +++ b/eform-client/src/app/modules/auth/auth.module.ts @@ -10,7 +10,8 @@ import { LoginComponent, ResetAdminPasswordComponent, RestorePasswordComponent, SignOutComponent, - AuthComponent + AuthComponent, + RestorePasswordConfirmationComponent } from './components'; @NgModule({ @@ -29,7 +30,8 @@ import { GoogleAuthenticatorComponent, ResetAdminPasswordComponent, SignOutComponent, - AuthComponent + AuthComponent, + RestorePasswordConfirmationComponent ] }) export class AuthModule { diff --git a/eform-client/src/app/modules/auth/auth.routing.ts b/eform-client/src/app/modules/auth/auth.routing.ts index b7ba0ec58a..1b5b804bfc 100644 --- a/eform-client/src/app/modules/auth/auth.routing.ts +++ b/eform-client/src/app/modules/auth/auth.routing.ts @@ -4,7 +4,7 @@ import { LoginComponent, RestorePasswordComponent, GoogleAuthenticatorComponent, - ResetAdminPasswordComponent, SignOutComponent, AuthComponent + ResetAdminPasswordComponent, SignOutComponent, AuthComponent, RestorePasswordConfirmationComponent } from './components'; const routes: Routes = [ @@ -23,6 +23,10 @@ const routes: Routes = [ path: 'restore-password', component: RestorePasswordComponent }, + { + path: 'restore-password-confirmation', + component: RestorePasswordConfirmationComponent + }, { path: 'reset-admin-password', component: ResetAdminPasswordComponent diff --git a/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.html b/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.html new file mode 100644 index 0000000000..f68b5133df --- /dev/null +++ b/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.html @@ -0,0 +1,35 @@ +
+
+ + vpn_key + + + +
+
+ + vpn_key + + + +
+ + + +
+
+ +
+ + diff --git a/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.ts b/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.ts new file mode 100644 index 0000000000..eaedafa968 --- /dev/null +++ b/eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.ts @@ -0,0 +1,39 @@ +import {Component, OnInit} from '@angular/core'; +import {AbstractControl, FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {ActivatedRoute, Router} from '@angular/router'; +import {ToastrService} from 'ngx-toastr'; +import {PasswordRestoreModel} from 'src/app/common/models/auth'; +import {AppSettingsService, AuthService} from 'src/app/common/services'; + +@Component({ + selector: 'app-restore-password-confirmation', + templateUrl: './restore-password-confirmation.component.html' +}) +export class RestorePasswordConfirmationComponent implements OnInit{ + submitRestoreModel: PasswordRestoreModel = new PasswordRestoreModel(); + spinnerStatus = false; + + constructor(private router: Router, + private authService: AuthService, + private settingsService: AppSettingsService, + private fb: FormBuilder, + private toastrService: ToastrService, + private route: ActivatedRoute) {} + + ngOnInit() { + this.route.queryParams.subscribe(params => { + this.submitRestoreModel.userId = params['userId']; + this.submitRestoreModel.code = params['code']; + }); + } + + submitRestoreConfirmationForm(): void { + this.authService.restorePassword(this.submitRestoreModel).subscribe((result) => { + if (result && result.success) { + this.router.navigate(['']); + this.toastrService.success('Password set successfully'); + } + } + ); + } +} diff --git a/eform-client/src/app/modules/auth/components/auth/restore-password/restore-password.component.html b/eform-client/src/app/modules/auth/components/auth/restore-password/restore-password.component.html index fb9cffa2a9..c2903773ad 100644 --- a/eform-client/src/app/modules/auth/components/auth/restore-password/restore-password.component.html +++ b/eform-client/src/app/modules/auth/components/auth/restore-password/restore-password.component.html @@ -4,7 +4,8 @@ mail - + diff --git a/eform-client/src/app/modules/auth/components/index.ts b/eform-client/src/app/modules/auth/components/index.ts index bb17ce656c..92098f7d7a 100644 --- a/eform-client/src/app/modules/auth/components/index.ts +++ b/eform-client/src/app/modules/auth/components/index.ts @@ -1,4 +1,5 @@ export * from './auth/restore-password/restore-password.component'; +export * from './auth/restore-password-confirmation/restore-password-confirmation.component'; export * from './auth/login/login.component'; export * from './google-authenticator/google-authenticator.component'; export * from './auth/reset-admin-password/reset-admin-password.component';