Skip to content

Commit b682e52

Browse files
committed
2 parents 592b7cc + 079519f commit b682e52

File tree

8 files changed

+88
-6
lines changed

8 files changed

+88
-6
lines changed

eFormAPI/eFormAPI/Controllers/AccountController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task<OperationResult> ForgotPassword(ForgotPasswordModel model)
144144
}
145145
var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
146146
var link = ConfigurationManager.AppSettings["app:siteLink"];
147-
link = $"{link}/login/restore-password?userId={user.Id}&code={code}";
147+
link = $"{link}/restore-password-confirmation?userId={user.Id}&code={code}";
148148
await UserManager.SendEmailAsync(user.Id, "Reset Password",
149149
"Please reset your password by clicking <a href=\"" + link + "\">here</a>");
150150
return new OperationResult(true);

eform-client/src/app/common/services/base.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class BaseService {
124124

125125
private logOutWhenTokenFalse() {
126126
localStorage.clear();
127-
this.router.navigate(['/auth/login']).then();
127+
this.router.navigate(['/auth']).then();
128128
}
129129

130130

eform-client/src/app/modules/auth/auth.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
LoginComponent,
1111
ResetAdminPasswordComponent,
1212
RestorePasswordComponent, SignOutComponent,
13-
AuthComponent
13+
AuthComponent,
14+
RestorePasswordConfirmationComponent
1415
} from './components';
1516

1617
@NgModule({
@@ -29,7 +30,8 @@ import {
2930
GoogleAuthenticatorComponent,
3031
ResetAdminPasswordComponent,
3132
SignOutComponent,
32-
AuthComponent
33+
AuthComponent,
34+
RestorePasswordConfirmationComponent
3335
]
3436
})
3537
export class AuthModule {

eform-client/src/app/modules/auth/auth.routing.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
LoginComponent,
55
RestorePasswordComponent,
66
GoogleAuthenticatorComponent,
7-
ResetAdminPasswordComponent, SignOutComponent, AuthComponent
7+
ResetAdminPasswordComponent, SignOutComponent, AuthComponent, RestorePasswordConfirmationComponent
88
} from './components';
99

1010
const routes: Routes = [
@@ -23,6 +23,10 @@ const routes: Routes = [
2323
path: 'restore-password',
2424
component: RestorePasswordComponent
2525
},
26+
{
27+
path: 'restore-password-confirmation',
28+
component: RestorePasswordConfirmationComponent
29+
},
2630
{
2731
path: 'reset-admin-password',
2832
component: ResetAdminPasswordComponent
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<div class="mb-2">
2+
<div class="md-form">
3+
<i class="material-icons prefix">
4+
vpn_key
5+
</i>
6+
<input mdbInputDirective [mdbValidate]="false"
7+
type="password" [(ngModel)]="submitRestoreModel.password"
8+
id="newPassword" name="newPassword" class="form-control">
9+
<label for="newPassword">{{'New Password' | translate}}</label>
10+
</div>
11+
<div class="md-form">
12+
<i class="material-icons prefix">
13+
vpn_key
14+
</i>
15+
<input mdbInputDirective [mdbValidate]="false"
16+
type="password" id="newPasswordConfirmation"
17+
[(ngModel)]="submitRestoreModel.confirmPassword"
18+
name="newPasswordConfirmation" class="form-control">
19+
<label for="newPasswordConfirmation">{{'Confirm Password' | translate}}</label>
20+
</div>
21+
22+
<button mdbWavesEffect type="button" class="btn btn-success btn-lg btn-block"
23+
[disabled]="!submitRestoreModel.password || !submitRestoreModel.confirmPassword"
24+
(click)="submitRestoreConfirmationForm()">
25+
{{'Update Password' | translate}}
26+
</button>
27+
28+
</div>
29+
<div class="d-flex flex-column">
30+
<div class="p-0">
31+
<a class="link-primary" [routerLink]="['/auth']">< {{'Back to login' | translate}}</a>
32+
</div>
33+
</div>
34+
35+
<eform-spinner [spinnerVisibility]="spinnerStatus"></eform-spinner>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {Component, OnInit} from '@angular/core';
2+
import {AbstractControl, FormBuilder, FormGroup, Validators} from '@angular/forms';
3+
import {ActivatedRoute, Router} from '@angular/router';
4+
import {ToastrService} from 'ngx-toastr';
5+
import {PasswordRestoreModel} from 'src/app/common/models/auth';
6+
import {AppSettingsService, AuthService} from 'src/app/common/services';
7+
8+
@Component({
9+
selector: 'app-restore-password-confirmation',
10+
templateUrl: './restore-password-confirmation.component.html'
11+
})
12+
export class RestorePasswordConfirmationComponent implements OnInit{
13+
submitRestoreModel: PasswordRestoreModel = new PasswordRestoreModel();
14+
spinnerStatus = false;
15+
16+
constructor(private router: Router,
17+
private authService: AuthService,
18+
private settingsService: AppSettingsService,
19+
private fb: FormBuilder,
20+
private toastrService: ToastrService,
21+
private route: ActivatedRoute) {}
22+
23+
ngOnInit() {
24+
this.route.queryParams.subscribe(params => {
25+
this.submitRestoreModel.userId = params['userId'];
26+
this.submitRestoreModel.code = params['code'];
27+
});
28+
}
29+
30+
submitRestoreConfirmationForm(): void {
31+
this.authService.restorePassword(this.submitRestoreModel).subscribe((result) => {
32+
if (result && result.success) {
33+
this.router.navigate(['']);
34+
this.toastrService.success('Password set successfully');
35+
}
36+
}
37+
);
38+
}
39+
}

eform-client/src/app/modules/auth/components/auth/restore-password/restore-password.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<i class="material-icons prefix">
55
mail
66
</i>
7-
<input mdbInputDirective type="text" id="email" name="email" class="form-control">
7+
<input mdbInputDirective [mdbValidate]="false"
8+
formControlName="email" type="text" id="email" name="email" class="form-control">
89
<label for="email">{{'Email' | translate}}</label>
910
</div>
1011
</form>

eform-client/src/app/modules/auth/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './auth/restore-password/restore-password.component';
2+
export * from './auth/restore-password-confirmation/restore-password-confirmation.component';
23
export * from './auth/login/login.component';
34
export * from './google-authenticator/google-authenticator.component';
45
export * from './auth/reset-admin-password/reset-admin-password.component';

0 commit comments

Comments
 (0)