UI: Fixed reset password service

This commit is contained in:
Artem Dzhereleiko 2023-04-18 16:41:29 +03:00
parent bd81290826
commit 533f084648
2 changed files with 7 additions and 6 deletions

View File

@ -156,10 +156,8 @@ export class AuthService {
));
}
public resetPassword(resetToken: string, password: string) {
this.http.post('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions()).subscribe(
() => { this.router.navigateByUrl('login'); }, () => {}
);
public resetPassword(resetToken: string, password: string): Observable<LoginResponse> {
return this.http.post<LoginResponse>('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions());
}
public changePassword(currentPassword: string, newPassword: string, config?: RequestConfig) {

View File

@ -22,7 +22,7 @@ import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs';
@Component({
@ -44,6 +44,7 @@ export class ResetPasswordComponent extends PageComponent implements OnInit, OnD
constructor(protected store: Store<AppState>,
private route: ActivatedRoute,
private router: Router,
private authService: AuthService,
private translate: TranslateService,
public fb: FormBuilder) {
@ -71,7 +72,9 @@ export class ResetPasswordComponent extends PageComponent implements OnInit, OnD
} else {
this.authService.resetPassword(
this.resetToken,
this.resetPassword.get('newPassword').value);
this.resetPassword.get('newPassword').value).subscribe(
() => this.router.navigateByUrl('login')
);
}
}
}