resetPassword in AuthController now returns nothing instead of token pair, just updates password. Button 'reset password' in reset password form now redirects to login page

This commit is contained in:
AndriiD 2023-01-07 18:00:49 +02:00
parent 88fcd9b63a
commit 3d9df20d45
3 changed files with 6 additions and 9 deletions

View File

@ -278,7 +278,7 @@ public class AuthController extends BaseController {
@RequestMapping(value = "/noauth/resetPassword", method = RequestMethod.POST) @RequestMapping(value = "/noauth/resetPassword", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK) @ResponseStatus(value = HttpStatus.OK)
@ResponseBody @ResponseBody
public JwtPair resetPassword( public void resetPassword(
@ApiParam(value = "Reset password request.") @ApiParam(value = "Reset password request.")
@RequestBody ResetPasswordRequest resetPasswordRequest, @RequestBody ResetPasswordRequest resetPasswordRequest,
HttpServletRequest request) throws ThingsboardException { HttpServletRequest request) throws ThingsboardException {
@ -305,7 +305,6 @@ public class AuthController extends BaseController {
eventPublisher.publishEvent(new UserCredentialsInvalidationEvent(securityUser.getId())); eventPublisher.publishEvent(new UserCredentialsInvalidationEvent(securityUser.getId()));
return tokenFactory.createTokenPair(securityUser);
} else { } else {
throw new ThingsboardException("Invalid reset token!", ThingsboardErrorCode.BAD_REQUEST_PARAMS); throw new ThingsboardException("Invalid reset token!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
} }

View File

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

View File

@ -71,7 +71,7 @@ export class ResetPasswordComponent extends PageComponent implements OnInit, OnD
} else { } else {
this.authService.resetPassword( this.authService.resetPassword(
this.resetToken, this.resetToken,
this.resetPassword.get('newPassword').value).subscribe(); this.resetPassword.get('newPassword').value);
} }
} }
} }