-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: current password is required when changing own password (#597)
- Loading branch information
Showing
9 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
agate-core/src/main/java/org/obiba/agate/service/CurrentPasswordInvalidException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2019 OBiBa. All rights reserved. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the GNU Public License v3.0. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.obiba.agate.service; | ||
|
||
public class CurrentPasswordInvalidException extends RuntimeException { | ||
|
||
public CurrentPasswordInvalidException() { | ||
super("The current password is invalid"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
agate-rest/src/main/java/org/obiba/agate/web/rest/CurrentPasswordInvalidExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2019 OBiBa. All rights reserved. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the GNU Public License v3.0. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.obiba.agate.web.rest; | ||
|
||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.Provider; | ||
import org.obiba.agate.service.CurrentPasswordInvalidException; | ||
import org.obiba.agate.service.PasswordNotChangedException; | ||
import org.obiba.jersey.exceptionmapper.AbstractErrorDtoExceptionMapper; | ||
import org.obiba.web.model.ErrorDtos; | ||
|
||
|
||
@Provider | ||
public class CurrentPasswordInvalidExceptionMapper extends AbstractErrorDtoExceptionMapper<CurrentPasswordInvalidException> { | ||
|
||
@Override | ||
protected Response.Status getStatus() { | ||
return Response.Status.BAD_REQUEST; | ||
} | ||
|
||
@Override | ||
protected ErrorDtos.ClientErrorDto getErrorDto(CurrentPasswordInvalidException e) { | ||
return ErrorDtos.ClientErrorDto.newBuilder() // | ||
.setCode(getStatus().getStatusCode()) // | ||
.setMessageTemplate("server.error.password.current-invalid") // | ||
.setMessage(e.getMessage()) // | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters