Resolve conflicts
This commit is contained in:
		
						commit
						9e3538a431
					
				@ -228,10 +228,9 @@ public class AuthController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "Reset password (resetPassword)",
 | 
			
		||||
            notes = "Checks the password reset token and updates the password. " +
 | 
			
		||||
                    "If token is valid, returns the object that contains [JWT](https://jwt.io/) access and refresh tokens. " +
 | 
			
		||||
                    "If token is not valid, returns '400 Bad Request'.")
 | 
			
		||||
    @PostMapping(value = "/noauth/resetPassword")
 | 
			
		||||
    public JwtPair resetPassword(@Parameter(description = "Reset password request.")
 | 
			
		||||
    public void resetPassword(@Parameter(description = "Reset password request.")
 | 
			
		||||
                                 @RequestBody ResetPasswordRequest resetPasswordRequest,
 | 
			
		||||
                                 HttpServletRequest request) throws ThingsboardException {
 | 
			
		||||
        String resetToken = resetPasswordRequest.getResetToken();
 | 
			
		||||
@ -263,8 +262,6 @@ public class AuthController extends BaseController {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            eventPublisher.publishEvent(new UserCredentialsInvalidationEvent(securityUser.getId()));
 | 
			
		||||
 | 
			
		||||
            return tokenFactory.createTokenPair(securityUser);
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new ThingsboardException("Invalid reset token!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -233,16 +233,9 @@ public class UserControllerTest extends AbstractControllerTest {
 | 
			
		||||
                .put("password", "testPassword2");
 | 
			
		||||
 | 
			
		||||
        Mockito.doNothing().when(mailService).sendPasswordWasResetEmail(anyString(), anyString());
 | 
			
		||||
        JsonNode tokenInfo = readResponse(
 | 
			
		||||
                doPost("/api/noauth/resetPassword", resetPasswordRequest)
 | 
			
		||||
                        .andExpect(status().isOk()), JsonNode.class);
 | 
			
		||||
        doPost("/api/noauth/resetPassword", resetPasswordRequest)
 | 
			
		||||
                .andExpect(status().isOk());
 | 
			
		||||
        Mockito.verify(mailService).sendPasswordWasResetEmail(anyString(), anyString());
 | 
			
		||||
        validateAndSetJwtToken(tokenInfo, email);
 | 
			
		||||
 | 
			
		||||
        doGet("/api/auth/user")
 | 
			
		||||
                .andExpect(status().isOk())
 | 
			
		||||
                .andExpect(jsonPath("$.authority", is(Authority.TENANT_ADMIN.name())))
 | 
			
		||||
                .andExpect(jsonPath("$.email", is(email)));
 | 
			
		||||
 | 
			
		||||
        resetTokens();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -152,12 +152,8 @@ export class AuthService {
 | 
			
		||||
      ));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public resetPassword(resetToken: string, password: string): Observable<LoginResponse> {
 | 
			
		||||
    return this.http.post<LoginResponse>('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions()).pipe(
 | 
			
		||||
      tap((loginResponse: LoginResponse) => {
 | 
			
		||||
          this.setUserFromJwtToken(loginResponse.token, loginResponse.refreshToken, true);
 | 
			
		||||
        }
 | 
			
		||||
      ));
 | 
			
		||||
  public resetPassword(resetToken: string, password: string): Observable<void> {
 | 
			
		||||
    return this.http.post<void>('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public changePassword(currentPassword: string, newPassword: string, config?: RequestConfig) {
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ import { PageComponent } from '@shared/components/page.component';
 | 
			
		||||
import { UntypedFormBuilder } 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: UntypedFormBuilder) {
 | 
			
		||||
@ -71,7 +72,9 @@ export class ResetPasswordComponent extends PageComponent implements OnInit, OnD
 | 
			
		||||
    } else {
 | 
			
		||||
      this.authService.resetPassword(
 | 
			
		||||
        this.resetToken,
 | 
			
		||||
        this.resetPassword.get('newPassword').value).subscribe();
 | 
			
		||||
        this.resetPassword.get('newPassword').value).subscribe(
 | 
			
		||||
        () => this.router.navigateByUrl('login')
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user