Resolve conflicts
This commit is contained in:
commit
9e3538a431
@ -228,10 +228,9 @@ public class AuthController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation(value = "Reset password (resetPassword)",
|
@ApiOperation(value = "Reset password (resetPassword)",
|
||||||
notes = "Checks the password reset token and updates the password. " +
|
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'.")
|
"If token is not valid, returns '400 Bad Request'.")
|
||||||
@PostMapping(value = "/noauth/resetPassword")
|
@PostMapping(value = "/noauth/resetPassword")
|
||||||
public JwtPair resetPassword(@Parameter(description = "Reset password request.")
|
public void resetPassword(@Parameter(description = "Reset password request.")
|
||||||
@RequestBody ResetPasswordRequest resetPasswordRequest,
|
@RequestBody ResetPasswordRequest resetPasswordRequest,
|
||||||
HttpServletRequest request) throws ThingsboardException {
|
HttpServletRequest request) throws ThingsboardException {
|
||||||
String resetToken = resetPasswordRequest.getResetToken();
|
String resetToken = resetPasswordRequest.getResetToken();
|
||||||
@ -263,8 +262,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -233,16 +233,9 @@ public class UserControllerTest extends AbstractControllerTest {
|
|||||||
.put("password", "testPassword2");
|
.put("password", "testPassword2");
|
||||||
|
|
||||||
Mockito.doNothing().when(mailService).sendPasswordWasResetEmail(anyString(), anyString());
|
Mockito.doNothing().when(mailService).sendPasswordWasResetEmail(anyString(), anyString());
|
||||||
JsonNode tokenInfo = readResponse(
|
|
||||||
doPost("/api/noauth/resetPassword", resetPasswordRequest)
|
doPost("/api/noauth/resetPassword", resetPasswordRequest)
|
||||||
.andExpect(status().isOk()), JsonNode.class);
|
.andExpect(status().isOk());
|
||||||
Mockito.verify(mailService).sendPasswordWasResetEmail(anyString(), anyString());
|
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();
|
resetTokens();
|
||||||
|
|
||||||
|
|||||||
@ -152,12 +152,8 @@ export class AuthService {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetPassword(resetToken: string, password: string): Observable<LoginResponse> {
|
public resetPassword(resetToken: string, password: string): Observable<void> {
|
||||||
return this.http.post<LoginResponse>('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions()).pipe(
|
return this.http.post<void>('/api/noauth/resetPassword', {resetToken, password}, defaultHttpOptions());
|
||||||
tap((loginResponse: LoginResponse) => {
|
|
||||||
this.setUserFromJwtToken(loginResponse.token, loginResponse.refreshToken, true);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public changePassword(currentPassword: string, newPassword: string, config?: RequestConfig) {
|
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 { UntypedFormBuilder } from '@angular/forms';
|
||||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -44,6 +44,7 @@ export class ResetPasswordComponent extends PageComponent implements OnInit, OnD
|
|||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
public fb: UntypedFormBuilder) {
|
public fb: UntypedFormBuilder) {
|
||||||
@ -71,7 +72,9 @@ 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).subscribe(
|
||||||
|
() => this.router.navigateByUrl('login')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user