Skip to content
Snippets Groups Projects
Verified Commit 4cee1153 authored by Martin Weise's avatar Martin Weise
Browse files

Fixed the build and user login

parent d65e3e6e
No related branches found
No related tags found
1 merge request!379Fixed the sync
Showing
with 45 additions and 406 deletions
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
author: Martin Weise author: Martin Weise
--- ---
## v1.6.4 (2025-02-13) ## v1.6.4 (2025-02-14)
[:simple-gitlab: GitLab Release](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tags/v1.6.4) [:simple-gitlab: GitLab Release](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tags/v1.6.4)
...@@ -10,8 +10,8 @@ author: Martin Weise ...@@ -10,8 +10,8 @@ author: Martin Weise
#### Fixes #### Fixes
* Fixed a bug where the users were not synced with the Metadata Database and the API Password was not recommended on * Fixed a bug where the users were not synced with the Metadata Database
first login in [#489](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/489). in [#489](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/489).
## v1.6.3 (2025-02-05) ## v1.6.3 (2025-02-05)
......
No preview for this file type
...@@ -4,11 +4,11 @@ import at.tuwien.api.auth.CreateUserDto; ...@@ -4,11 +4,11 @@ import at.tuwien.api.auth.CreateUserDto;
import at.tuwien.api.error.ApiErrorDto; import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.api.user.UserBriefDto; import at.tuwien.api.user.UserBriefDto;
import at.tuwien.api.user.UserDto; import at.tuwien.api.user.UserDto;
import at.tuwien.api.user.UserPasswordDto;
import at.tuwien.api.user.UserUpdateDto; import at.tuwien.api.user.UserUpdateDto;
import at.tuwien.entities.database.Database;
import at.tuwien.entities.user.User; import at.tuwien.entities.user.User;
import at.tuwien.exception.*; import at.tuwien.exception.AuthServiceException;
import at.tuwien.exception.NotAllowedException;
import at.tuwien.exception.UserNotFoundException;
import at.tuwien.mapper.MetadataMapper; import at.tuwien.mapper.MetadataMapper;
import at.tuwien.service.AuthenticationService; import at.tuwien.service.AuthenticationService;
import at.tuwien.service.DatabaseService; import at.tuwien.service.DatabaseService;
...@@ -212,60 +212,4 @@ public class UserEndpoint extends AbstractEndpoint { ...@@ -212,60 +212,4 @@ public class UserEndpoint extends AbstractEndpoint {
userService.modify(user, data))); userService.modify(user, data)));
} }
@PutMapping("/{userId}/password")
@Transactional(rollbackFor = {Exception.class})
@PreAuthorize("isAuthenticated()")
@Observed(name = "dbrepo_user_password_modify")
@Operation(summary = "Update user password",
description = "Updates password of user with id. Requires authentication.",
security = {@SecurityRequirement(name = "bearerAuth"), @SecurityRequirement(name = "basicAuth")})
@ApiResponses(value = {
@ApiResponse(responseCode = "202",
description = "Modified user password"),
@ApiResponse(responseCode = "400",
description = "Invalid password payload",
content = {@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiErrorDto.class))}),
@ApiResponse(responseCode = "403",
description = "Not allowed to change foreign user password",
content = {@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiErrorDto.class))}),
@ApiResponse(responseCode = "404",
description = "Failed to find database/user in metadata database",
content = {@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiErrorDto.class))}),
@ApiResponse(responseCode = "502",
description = "Connection to auth service failed",
content = {@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiErrorDto.class))}),
@ApiResponse(responseCode = "503",
description = "Failed to get user in auth service",
content = {@Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<Void> password(@NotNull @PathVariable("userId") UUID userId,
@NotNull @Valid @RequestBody UserPasswordDto data,
@NotNull Principal principal) throws NotAllowedException,
UserNotFoundException, DatabaseNotFoundException, DataServiceException,
DataServiceConnectionException, AuthServiceException {
log.debug("endpoint modify a user password, userId={}, principal.name={}", userId, principal.getName());
final User user = userService.findById(userId);
if (!user.getUsername().equals(principal.getName())) {
log.error("Failed to modify user password: not current user");
throw new NotAllowedException("Failed to modify user password: not current user");
}
for (Database database : databaseService.findAllAtLestReadAccess(userId)) {
databaseService.updatePassword(database, user);
}
userService.updatePassword(user, data);
authenticationService.setupFinished(user);
return ResponseEntity.accepted()
.build();
}
} }
...@@ -4,6 +4,7 @@ import at.tuwien.api.error.ApiErrorDto; ...@@ -4,6 +4,7 @@ import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.exception.*; import at.tuwien.exception.*;
import com.auth0.jwt.exceptions.TokenExpiredException; import com.auth0.jwt.exceptions.TokenExpiredException;
import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Hidden;
import jakarta.ws.rs.NotAuthorizedException;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -31,6 +32,20 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -31,6 +32,20 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, headers, response.getStatus()); return new ResponseEntity<>(response, headers, response.getStatus());
} }
@Hidden
@ResponseStatus(code = HttpStatus.UNAUTHORIZED)
@ExceptionHandler(NotAuthorizedException.class)
public ResponseEntity<ApiErrorDto> handle(NotAuthorizedException e) {
final HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/problem+json");
final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.UNAUTHORIZED)
.message(e.getLocalizedMessage())
.code("error.authentication.invalid")
.build();
return new ResponseEntity<>(response, headers, response.getStatus());
}
@Hidden @Hidden
@ResponseStatus(code = HttpStatus.NOT_FOUND) @ResponseStatus(code = HttpStatus.NOT_FOUND)
@ExceptionHandler(AccessNotFoundException.class) @ExceptionHandler(AccessNotFoundException.class)
......
...@@ -3,10 +3,11 @@ package at.tuwien.endpoints; ...@@ -3,10 +3,11 @@ package at.tuwien.endpoints;
import at.tuwien.api.auth.CreateUserDto; import at.tuwien.api.auth.CreateUserDto;
import at.tuwien.api.user.UserBriefDto; import at.tuwien.api.user.UserBriefDto;
import at.tuwien.api.user.UserDto; import at.tuwien.api.user.UserDto;
import at.tuwien.api.user.UserPasswordDto;
import at.tuwien.api.user.UserUpdateDto; import at.tuwien.api.user.UserUpdateDto;
import at.tuwien.entities.user.User; import at.tuwien.entities.user.User;
import at.tuwien.exception.*; import at.tuwien.exception.AuthServiceException;
import at.tuwien.exception.NotAllowedException;
import at.tuwien.exception.UserNotFoundException;
import at.tuwien.service.AuthenticationService; import at.tuwien.service.AuthenticationService;
import at.tuwien.service.DatabaseService; import at.tuwien.service.DatabaseService;
import at.tuwien.service.UserService; import at.tuwien.service.UserService;
...@@ -32,7 +33,8 @@ import java.util.List; ...@@ -32,7 +33,8 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
@Log4j2 @Log4j2
@SpringBootTest @SpringBootTest
...@@ -227,44 +229,6 @@ public class UserEndpointUnitTest extends AbstractUnitTest { ...@@ -227,44 +229,6 @@ public class UserEndpointUnitTest extends AbstractUnitTest {
modify_generic(USER_1_ID, USER_1, USER_1_PRINCIPAL, request); modify_generic(USER_1_ID, USER_1, USER_1_PRINCIPAL, request);
} }
@Test
@WithAnonymousUser
public void password_anonymous_fails() {
final UserPasswordDto request = UserPasswordDto.builder()
.password(USER_1_PASSWORD)
.build();
/* test */
assertThrows(org.springframework.security.access.AccessDeniedException.class, () -> {
password_generic(null, request);
});
}
@Test
@WithMockUser(username = USER_4_USERNAME)
public void password_noRoleForeign_fails() {
final UserPasswordDto request = UserPasswordDto.builder()
.password(USER_1_PASSWORD)
.build();
/* test */
assertThrows(NotAllowedException.class, () -> {
password_generic(USER_4_PRINCIPAL, request);
});
}
@Test
@WithMockUser(username = USER_1_USERNAME)
public void password_succeeds() throws NotAllowedException, DataServiceException, DataServiceConnectionException,
UserNotFoundException, DatabaseNotFoundException, AuthServiceException {
final UserPasswordDto request = UserPasswordDto.builder()
.password(USER_1_PASSWORD)
.build();
/* test */
password_generic(USER_1_PRINCIPAL, request);
}
@Test @Test
@WithAnonymousUser @WithAnonymousUser
public void create_anonymous_fails() { public void create_anonymous_fails() {
...@@ -364,30 +328,6 @@ public class UserEndpointUnitTest extends AbstractUnitTest { ...@@ -364,30 +328,6 @@ public class UserEndpointUnitTest extends AbstractUnitTest {
assertNotNull(body); assertNotNull(body);
} }
protected void password_generic(Principal principal, UserPasswordDto data) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, UserNotFoundException, DatabaseNotFoundException,
AuthServiceException {
/* mock */
when(userService.findById(USER_1_ID))
.thenReturn(USER_1);
doNothing()
.when(authenticationService)
.setupFinished(USER_1);
doNothing()
.when(userService)
.updatePassword(USER_1, data);
when(databaseService.findAllAtLestReadAccess(USER_1_ID))
.thenReturn(List.of(DATABASE_1));
doNothing()
.when(databaseService)
.updatePassword(DATABASE_1, USER_1);
/* test */
final ResponseEntity<?> response = userEndpoint.password(USER_1_ID, data, principal);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
}
protected void generic_create(CreateUserDto data) { protected void generic_create(CreateUserDto data) {
/* test */ /* test */
......
...@@ -4,6 +4,7 @@ import at.tuwien.api.error.ApiErrorDto; ...@@ -4,6 +4,7 @@ import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.exception.*; import at.tuwien.exception.*;
import at.tuwien.test.AbstractUnitTest; import at.tuwien.test.AbstractUnitTest;
import com.auth0.jwt.exceptions.TokenExpiredException; import com.auth0.jwt.exceptions.TokenExpiredException;
import jakarta.ws.rs.NotAuthorizedException;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -24,8 +25,7 @@ import java.util.Optional; ...@@ -24,8 +25,7 @@ import java.util.Optional;
import static at.tuwien.test.utils.EndpointUtils.getErrorCodes; import static at.tuwien.test.utils.EndpointUtils.getErrorCodes;
import static at.tuwien.test.utils.EndpointUtils.getExceptions; import static at.tuwien.test.utils.EndpointUtils.getExceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@Log4j2 @Log4j2
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
...@@ -51,7 +51,7 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -51,7 +51,7 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
Assertions.assertNotNull(exception.getDeclaredAnnotation(ResponseStatus.class).code()); Assertions.assertNotNull(exception.getDeclaredAnnotation(ResponseStatus.class).code());
Assertions.assertNotEquals(exception.getDeclaredAnnotation(ResponseStatus.class).code(), HttpStatus.INTERNAL_SERVER_ERROR); Assertions.assertNotEquals(exception.getDeclaredAnnotation(ResponseStatus.class).code(), HttpStatus.INTERNAL_SERVER_ERROR);
Assertions.assertNotNull(exception.getDeclaredAnnotation(ResponseStatus.class).reason(), "Exception " + exception.getName() + " does not provide a reason code"); Assertions.assertNotNull(exception.getDeclaredAnnotation(ResponseStatus.class).reason(), "Exception " + exception.getName() + " does not provide a reason code");
Assertions.assertTrue(errorCodes.contains(exception.getDeclaredAnnotation(ResponseStatus.class).reason()), "Exception code " + exception.getDeclaredAnnotation(ResponseStatus.class).reason() + " does have a reason code mapped in localized ui error messages"); assertTrue(errorCodes.contains(exception.getDeclaredAnnotation(ResponseStatus.class).reason()), "Exception code " + exception.getDeclaredAnnotation(ResponseStatus.class).reason() + " does have a reason code mapped in localized ui error messages");
/* handler method */ /* handler method */
assertEquals(method.getDeclaredAnnotation(ResponseStatus.class).code(), exception.getDeclaredAnnotation(ResponseStatus.class).code()); assertEquals(method.getDeclaredAnnotation(ResponseStatus.class).code(), exception.getDeclaredAnnotation(ResponseStatus.class).code());
} }
...@@ -70,6 +70,19 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -70,6 +70,19 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.token.expired", body.getCode()); assertEquals("error.token.expired", body.getCode());
} }
@Test
public void handle_notAuthorizedException_succeeds() {
/* test */
final ResponseEntity<ApiErrorDto> response = apiExceptionHandler.handle(new NotAuthorizedException("msg"));
assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
final ApiErrorDto body = response.getBody();
assertNotNull(body);
assertNotNull(body.getMessage());
assertEquals(HttpStatus.UNAUTHORIZED, body.getStatus());
assertEquals("error.authentication.invalid", body.getCode());
}
@Test @Test
public void handle_accessNotFoundException_succeeds() { public void handle_accessNotFoundException_succeeds() {
...@@ -135,7 +148,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -135,7 +148,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.auth.invalid", body.getCode()); assertEquals("error.auth.invalid", body.getCode());
} }
@Test @Test
public void handle_brokerServiceConnectionException_succeeds() { public void handle_brokerServiceConnectionException_succeeds() {
...@@ -149,7 +161,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -149,7 +161,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.broker.connection", body.getCode()); assertEquals("error.broker.connection", body.getCode());
} }
@Test @Test
public void handle_brokerServiceException_succeeds() { public void handle_brokerServiceException_succeeds() {
...@@ -163,7 +174,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -163,7 +174,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.broker.invalid", body.getCode()); assertEquals("error.broker.invalid", body.getCode());
} }
@Test @Test
public void handle_conceptNotFoundException_succeeds() { public void handle_conceptNotFoundException_succeeds() {
...@@ -177,7 +187,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -177,7 +187,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.concept.missing", body.getCode()); assertEquals("error.concept.missing", body.getCode());
} }
@Test @Test
public void handle_containerAlreadyExistsException_succeeds() { public void handle_containerAlreadyExistsException_succeeds() {
...@@ -191,7 +200,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -191,7 +200,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.container.exists", body.getCode()); assertEquals("error.container.exists", body.getCode());
} }
@Test @Test
public void handle_containerNotFoundException_succeeds() { public void handle_containerNotFoundException_succeeds() {
...@@ -205,7 +213,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -205,7 +213,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.container.missing", body.getCode()); assertEquals("error.container.missing", body.getCode());
} }
@Test @Test
public void handle_containerQuotaException_succeeds() { public void handle_containerQuotaException_succeeds() {
...@@ -219,7 +226,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -219,7 +226,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.container.quota", body.getCode()); assertEquals("error.container.quota", body.getCode());
} }
@Test @Test
public void handle_credentialsInvalidException_succeeds() { public void handle_credentialsInvalidException_succeeds() {
...@@ -233,7 +239,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -233,7 +239,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.user.credentials", body.getCode()); assertEquals("error.user.credentials", body.getCode());
} }
@Test @Test
public void handle_dataServiceConnectionException_succeeds() { public void handle_dataServiceConnectionException_succeeds() {
...@@ -247,7 +252,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -247,7 +252,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.data.connection", body.getCode()); assertEquals("error.data.connection", body.getCode());
} }
@Test @Test
public void handle_dataServiceException_succeeds() { public void handle_dataServiceException_succeeds() {
...@@ -261,7 +265,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -261,7 +265,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.data.invalid", body.getCode()); assertEquals("error.data.invalid", body.getCode());
} }
@Test @Test
public void handle_databaseMalformedException_succeeds() { public void handle_databaseMalformedException_succeeds() {
...@@ -275,7 +278,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -275,7 +278,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.database.invalid", body.getCode()); assertEquals("error.database.invalid", body.getCode());
} }
@Test @Test
public void handle_databaseNotFoundException_succeeds() { public void handle_databaseNotFoundException_succeeds() {
...@@ -289,7 +291,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -289,7 +291,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.database.missing", body.getCode()); assertEquals("error.database.missing", body.getCode());
} }
@Test @Test
public void handle_databaseUnavailableException_succeeds() { public void handle_databaseUnavailableException_succeeds() {
...@@ -303,7 +304,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -303,7 +304,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.database.connection", body.getCode()); assertEquals("error.database.connection", body.getCode());
} }
@Test @Test
public void handle_doiNotFoundException_succeeds() { public void handle_doiNotFoundException_succeeds() {
...@@ -317,7 +317,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -317,7 +317,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.doi.missing", body.getCode()); assertEquals("error.doi.missing", body.getCode());
} }
@Test @Test
public void handle_emailExistsException_succeeds() { public void handle_emailExistsException_succeeds() {
...@@ -331,7 +330,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -331,7 +330,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.user.email-exists", body.getCode()); assertEquals("error.user.email-exists", body.getCode());
} }
@Test @Test
public void handle_exchangeNotFoundException_succeeds() { public void handle_exchangeNotFoundException_succeeds() {
...@@ -345,7 +343,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -345,7 +343,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.exchange.missing", body.getCode()); assertEquals("error.exchange.missing", body.getCode());
} }
@Test @Test
public void handle_externalServiceException_succeeds() { public void handle_externalServiceException_succeeds() {
...@@ -359,7 +356,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -359,7 +356,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.external.invalid", body.getCode()); assertEquals("error.external.invalid", body.getCode());
} }
@Test @Test
public void handle_filterBadRequestException_succeeds() { public void handle_filterBadRequestException_succeeds() {
...@@ -373,7 +369,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -373,7 +369,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.semantic.filter", body.getCode()); assertEquals("error.semantic.filter", body.getCode());
} }
@Test @Test
public void handle_formatNotAvailableException_succeeds() { public void handle_formatNotAvailableException_succeeds() {
...@@ -387,7 +382,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -387,7 +382,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.identifier.format", body.getCode()); assertEquals("error.identifier.format", body.getCode());
} }
@Test @Test
public void handle_identifierNotFoundException_succeeds() { public void handle_identifierNotFoundException_succeeds() {
...@@ -401,7 +395,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -401,7 +395,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.identifier.missing", body.getCode()); assertEquals("error.identifier.missing", body.getCode());
} }
@Test @Test
public void handle_identifierNotSupportedException_succeeds() { public void handle_identifierNotSupportedException_succeeds() {
...@@ -415,7 +408,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -415,7 +408,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.identifier.unsupported", body.getCode()); assertEquals("error.identifier.unsupported", body.getCode());
} }
@Test @Test
public void handle_imageAlreadyExistsException_succeeds() { public void handle_imageAlreadyExistsException_succeeds() {
...@@ -429,7 +421,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -429,7 +421,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.image.exists", body.getCode()); assertEquals("error.image.exists", body.getCode());
} }
@Test @Test
public void handle_imageInvalidException_succeeds() { public void handle_imageInvalidException_succeeds() {
...@@ -443,7 +434,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -443,7 +434,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.image.invalid", body.getCode()); assertEquals("error.image.invalid", body.getCode());
} }
@Test @Test
public void handle_imageNotFoundException_succeeds() { public void handle_imageNotFoundException_succeeds() {
...@@ -457,7 +447,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -457,7 +447,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.image.missing", body.getCode()); assertEquals("error.image.missing", body.getCode());
} }
@Test @Test
public void handle_licenseNotFoundException_succeeds() { public void handle_licenseNotFoundException_succeeds() {
...@@ -471,7 +460,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -471,7 +460,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.license.missing", body.getCode()); assertEquals("error.license.missing", body.getCode());
} }
@Test @Test
public void handle_malformedException_succeeds() { public void handle_malformedException_succeeds() {
...@@ -485,7 +473,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -485,7 +473,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.request.invalid", body.getCode()); assertEquals("error.request.invalid", body.getCode());
} }
@Test @Test
public void handle_messageNotFoundException_succeeds() { public void handle_messageNotFoundException_succeeds() {
...@@ -499,7 +486,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -499,7 +486,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.message.missing", body.getCode()); assertEquals("error.message.missing", body.getCode());
} }
@Test @Test
public void handle_metadataServiceConnectionException_succeeds() { public void handle_metadataServiceConnectionException_succeeds() {
...@@ -513,7 +499,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -513,7 +499,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.metadata.connection", body.getCode()); assertEquals("error.metadata.connection", body.getCode());
} }
@Test @Test
public void handle_metadataServiceException_succeeds() { public void handle_metadataServiceException_succeeds() {
...@@ -527,7 +512,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -527,7 +512,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.metadata.invalid", body.getCode()); assertEquals("error.metadata.invalid", body.getCode());
} }
@Test @Test
public void handle_notAllowedException_succeeds() { public void handle_notAllowedException_succeeds() {
...@@ -541,7 +525,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -541,7 +525,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.request.forbidden", body.getCode()); assertEquals("error.request.forbidden", body.getCode());
} }
@Test @Test
public void handle_ontologyNotFoundException_succeeds() { public void handle_ontologyNotFoundException_succeeds() {
...@@ -555,7 +538,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -555,7 +538,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.ontology.missing", body.getCode()); assertEquals("error.ontology.missing", body.getCode());
} }
@Test @Test
public void handle_orcidNotFoundException_succeeds() { public void handle_orcidNotFoundException_succeeds() {
...@@ -569,7 +551,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -569,7 +551,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.orcid.missing", body.getCode()); assertEquals("error.orcid.missing", body.getCode());
} }
@Test @Test
public void handle_paginationException_succeeds() { public void handle_paginationException_succeeds() {
...@@ -583,7 +564,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -583,7 +564,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.request.pagination", body.getCode()); assertEquals("error.request.pagination", body.getCode());
} }
@Test @Test
public void handle_queryMalformedException_succeeds() { public void handle_queryMalformedException_succeeds() {
...@@ -597,7 +577,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -597,7 +577,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.query.invalid", body.getCode()); assertEquals("error.query.invalid", body.getCode());
} }
@Test @Test
public void handle_queryNotFoundException_succeeds() { public void handle_queryNotFoundException_succeeds() {
...@@ -611,7 +590,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -611,7 +590,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.query.missing", body.getCode()); assertEquals("error.query.missing", body.getCode());
} }
@Test @Test
public void handle_queryNotSupportedException_succeeds() { public void handle_queryNotSupportedException_succeeds() {
...@@ -625,7 +603,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -625,7 +603,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.query.invalid", body.getCode()); assertEquals("error.query.invalid", body.getCode());
} }
@Test @Test
public void handle_queryStoreCreateException_succeeds() { public void handle_queryStoreCreateException_succeeds() {
...@@ -639,7 +616,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -639,7 +616,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.store.invalid", body.getCode()); assertEquals("error.store.invalid", body.getCode());
} }
@Test @Test
public void handle_queryStoreGCException_succeeds() { public void handle_queryStoreGCException_succeeds() {
...@@ -653,7 +629,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -653,7 +629,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.store.clean", body.getCode()); assertEquals("error.store.clean", body.getCode());
} }
@Test @Test
public void handle_queryStoreInsertException_succeeds() { public void handle_queryStoreInsertException_succeeds() {
...@@ -667,7 +642,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -667,7 +642,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.store.insert", body.getCode()); assertEquals("error.store.insert", body.getCode());
} }
@Test @Test
public void handle_queryStorePersistException_succeeds() { public void handle_queryStorePersistException_succeeds() {
...@@ -681,7 +655,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -681,7 +655,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.store.persist", body.getCode()); assertEquals("error.store.persist", body.getCode());
} }
@Test @Test
public void handle_queueNotFoundException_succeeds() { public void handle_queueNotFoundException_succeeds() {
...@@ -695,7 +668,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -695,7 +668,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.queue.missing", body.getCode()); assertEquals("error.queue.missing", body.getCode());
} }
@Test @Test
public void handle_remoteUnavailableException_succeeds() { public void handle_remoteUnavailableException_succeeds() {
...@@ -709,7 +681,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -709,7 +681,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.metadata.privileged", body.getCode()); assertEquals("error.metadata.privileged", body.getCode());
} }
@Test @Test
public void handle_rorNotFoundException_succeeds() { public void handle_rorNotFoundException_succeeds() {
...@@ -723,7 +694,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -723,7 +694,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.ror.missing", body.getCode()); assertEquals("error.ror.missing", body.getCode());
} }
@Test @Test
public void handle_searchServiceConnectionException_succeeds() { public void handle_searchServiceConnectionException_succeeds() {
...@@ -737,7 +707,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -737,7 +707,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.search.connection", body.getCode()); assertEquals("error.search.connection", body.getCode());
} }
@Test @Test
public void handle_searchServiceException_succeeds() { public void handle_searchServiceException_succeeds() {
...@@ -751,7 +720,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -751,7 +720,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.search.invalid", body.getCode()); assertEquals("error.search.invalid", body.getCode());
} }
@Test @Test
public void handle_semanticEntityNotFoundException_succeeds() { public void handle_semanticEntityNotFoundException_succeeds() {
...@@ -765,7 +733,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -765,7 +733,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.semantic.missing", body.getCode()); assertEquals("error.semantic.missing", body.getCode());
} }
@Test @Test
public void handle_sortException_succeeds() { public void handle_sortException_succeeds() {
...@@ -779,7 +746,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -779,7 +746,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.request.sort", body.getCode()); assertEquals("error.request.sort", body.getCode());
} }
@Test @Test
public void handle_storageNotFoundException_succeeds() { public void handle_storageNotFoundException_succeeds() {
...@@ -793,7 +759,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -793,7 +759,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.storage.missing", body.getCode()); assertEquals("error.storage.missing", body.getCode());
} }
@Test @Test
public void handle_storageUnavailableException_succeeds() { public void handle_storageUnavailableException_succeeds() {
...@@ -807,7 +772,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -807,7 +772,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.storage.invalid", body.getCode()); assertEquals("error.storage.invalid", body.getCode());
} }
@Test @Test
public void handle_tableExistsException_succeeds() { public void handle_tableExistsException_succeeds() {
...@@ -821,7 +785,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -821,7 +785,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.table.exists", body.getCode()); assertEquals("error.table.exists", body.getCode());
} }
@Test @Test
public void handle_tableMalformedException_succeeds() { public void handle_tableMalformedException_succeeds() {
...@@ -835,7 +798,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -835,7 +798,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.table.invalid", body.getCode()); assertEquals("error.table.invalid", body.getCode());
} }
@Test @Test
public void handle_tableNotFoundException_succeeds() { public void handle_tableNotFoundException_succeeds() {
...@@ -849,7 +811,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -849,7 +811,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.table.missing", body.getCode()); assertEquals("error.table.missing", body.getCode());
} }
@Test @Test
public void handle_tableSchemaException_succeeds() { public void handle_tableSchemaException_succeeds() {
...@@ -863,7 +824,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -863,7 +824,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.schema.table", body.getCode()); assertEquals("error.schema.table", body.getCode());
} }
@Test @Test
public void handle_unitNotFoundException_succeeds() { public void handle_unitNotFoundException_succeeds() {
...@@ -877,7 +837,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -877,7 +837,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.unit.missing", body.getCode()); assertEquals("error.unit.missing", body.getCode());
} }
@Test @Test
public void handle_uriMalformedException_succeeds() { public void handle_uriMalformedException_succeeds() {
...@@ -891,7 +850,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -891,7 +850,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.semantics.uri", body.getCode()); assertEquals("error.semantics.uri", body.getCode());
} }
@Test @Test
public void handle_userExistsException_succeeds() { public void handle_userExistsException_succeeds() {
...@@ -905,7 +863,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -905,7 +863,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.user.exists", body.getCode()); assertEquals("error.user.exists", body.getCode());
} }
@Test @Test
public void handle_userNotFoundException_succeeds() { public void handle_userNotFoundException_succeeds() {
...@@ -919,7 +876,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -919,7 +876,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.user.missing", body.getCode()); assertEquals("error.user.missing", body.getCode());
} }
@Test @Test
public void handle_viewMalformedException_succeeds() { public void handle_viewMalformedException_succeeds() {
...@@ -933,7 +889,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -933,7 +889,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.view.invalid", body.getCode()); assertEquals("error.view.invalid", body.getCode());
} }
@Test @Test
public void handle_viewNotFoundException_succeeds() { public void handle_viewNotFoundException_succeeds() {
...@@ -947,7 +902,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest { ...@@ -947,7 +902,6 @@ public class ApiExceptionHandlerTest extends AbstractUnitTest {
assertEquals("error.view.missing", body.getCode()); assertEquals("error.view.missing", body.getCode());
} }
@Test @Test
public void handle_viewSchemaException_succeeds() { public void handle_viewSchemaException_succeeds() {
......
...@@ -586,11 +586,6 @@ public class PrometheusEndpointMvcTest extends AbstractUnitTest { ...@@ -586,11 +586,6 @@ public class PrometheusEndpointMvcTest extends AbstractUnitTest {
} catch (Exception e) { } catch (Exception e) {
/* ignore */ /* ignore */
} }
try {
userEndpoint.password(USER_1_ID, USER_1_PASSWORD_DTO, USER_1_PRINCIPAL);
} catch (Exception e) {
/* ignore */
}
/* test */ /* test */
for (String metric : List.of("dbrepo_users_list", "dbrepo_user_find", "dbrepo_user_modify", for (String metric : List.of("dbrepo_users_list", "dbrepo_user_find", "dbrepo_user_modify",
......
...@@ -3,7 +3,6 @@ package at.tuwien.service; ...@@ -3,7 +3,6 @@ package at.tuwien.service;
import at.tuwien.api.user.UserUpdateDto; import at.tuwien.api.user.UserUpdateDto;
import at.tuwien.entities.user.User; import at.tuwien.entities.user.User;
import at.tuwien.exception.AuthServiceException; import at.tuwien.exception.AuthServiceException;
import at.tuwien.exception.UserExistsException;
import at.tuwien.exception.UserNotFoundException; import at.tuwien.exception.UserNotFoundException;
import at.tuwien.gateway.KeycloakGateway; import at.tuwien.gateway.KeycloakGateway;
import at.tuwien.repository.UserRepository; import at.tuwien.repository.UserRepository;
...@@ -124,20 +123,4 @@ public class UserServicePersistenceTest extends AbstractUnitTest { ...@@ -124,20 +123,4 @@ public class UserServicePersistenceTest extends AbstractUnitTest {
userService.findById(USER_2_ID); userService.findById(USER_2_ID);
}); });
} }
@Test
public void validateUsernameNotExists_succeeds() throws UserExistsException {
/* test */
userService.validateUsernameNotExists(USER_2_USERNAME);
}
@Test
public void validateUsernameNotExists_fails() {
/* test */
assertThrows(UserExistsException.class, () -> {
userService.validateUsernameNotExists(USER_1_USERNAME);
});
}
} }
...@@ -3,7 +3,6 @@ package at.tuwien.service; ...@@ -3,7 +3,6 @@ package at.tuwien.service;
import at.tuwien.entities.user.User; import at.tuwien.entities.user.User;
import at.tuwien.exception.AuthServiceException; import at.tuwien.exception.AuthServiceException;
import at.tuwien.exception.UserNotFoundException; import at.tuwien.exception.UserNotFoundException;
import at.tuwien.gateway.KeycloakGateway;
import at.tuwien.repository.UserRepository; import at.tuwien.repository.UserRepository;
import at.tuwien.test.AbstractUnitTest; import at.tuwien.test.AbstractUnitTest;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
...@@ -19,15 +18,13 @@ import java.util.Optional; ...@@ -19,15 +18,13 @@ import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest @SpringBootTest
public class UserServiceUnitTest extends AbstractUnitTest { public class UserServiceUnitTest extends AbstractUnitTest {
@MockBean
private KeycloakGateway keycloakGateway;
@MockBean @MockBean
private UserRepository userRepository; private UserRepository userRepository;
...@@ -92,22 +89,6 @@ public class UserServiceUnitTest extends AbstractUnitTest { ...@@ -92,22 +89,6 @@ public class UserServiceUnitTest extends AbstractUnitTest {
assertEquals(USER_1_USERNAME, response.getUsername()); assertEquals(USER_1_USERNAME, response.getUsername());
} }
@Test
public void updatePassword_succeeds() throws UserNotFoundException, AuthServiceException {
/* mock */
doNothing()
.when(keycloakGateway)
.setupFinished(USER_1_ID);
when(userRepository.findById(USER_1_ID))
.thenReturn(Optional.of(USER_1));
when(userRepository.save(any(User.class)))
.thenReturn(USER_1);
/* test */
userService.updatePassword(USER_1, USER_1_PASSWORD_DTO);
}
@Test @Test
public void findByUsername_fails() { public void findByUsername_fails() {
......
...@@ -57,21 +57,5 @@ public interface UserService { ...@@ -57,21 +57,5 @@ public interface UserService {
*/ */
User modify(User user, UserUpdateDto data) throws UserNotFoundException, AuthServiceException; User modify(User user, UserUpdateDto data) throws UserNotFoundException, AuthServiceException;
/**
* Updates the user password for a user with given id in the metadata database.
*
* @param user The user.
* @param data The new password.
*/
void updatePassword(User user, UserPasswordDto data);
/**
* Validates if a user with the given username already exists in the metadata database.
*
* @param username The username.
* @throws UserExistsException The user with this username already exists.
*/
void validateUsernameNotExists(String username) throws UserExistsException;
String getMariaDbPassword(String password); String getMariaDbPassword(String password);
} }
package at.tuwien.service.impl; package at.tuwien.service.impl;
import at.tuwien.api.auth.CreateUserDto; import at.tuwien.api.auth.CreateUserDto;
import at.tuwien.api.user.UserPasswordDto;
import at.tuwien.api.user.UserUpdateDto; import at.tuwien.api.user.UserUpdateDto;
import at.tuwien.entities.user.User; import at.tuwien.entities.user.User;
import at.tuwien.exception.AuthServiceException; import at.tuwien.exception.AuthServiceException;
import at.tuwien.exception.UserExistsException;
import at.tuwien.exception.UserNotFoundException; import at.tuwien.exception.UserNotFoundException;
import at.tuwien.gateway.KeycloakGateway; import at.tuwien.gateway.KeycloakGateway;
import at.tuwien.repository.UserRepository; import at.tuwien.repository.UserRepository;
...@@ -100,21 +98,6 @@ public class UserServiceImpl implements UserService { ...@@ -100,21 +98,6 @@ public class UserServiceImpl implements UserService {
return user; return user;
} }
@Override
public void updatePassword(User user, UserPasswordDto data) {
user.setMariadbPassword(getMariaDbPassword(data.getPassword()));
/* update at metadata database */
userRepository.save(user);
log.info("Updated password of user with id: {}", user.getId());
}
@Override
public void validateUsernameNotExists(String username) throws UserExistsException {
if (userRepository.existsByUsername(username)) {
throw new UserExistsException("User with username " + username + " already exists");
}
}
@Override @Override
public String getMariaDbPassword(String password) { public String getMariaDbPassword(String password) {
final byte[] utf8 = password.getBytes(StandardCharsets.UTF_8); final byte[] utf8 = password.getBytes(StandardCharsets.UTF_8);
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
<v-tab <v-tab
:text="$t('toolbars.user.info')" :text="$t('toolbars.user.info')"
to="/user/info" /> to="/user/info" />
<v-tab
:text="$t('toolbars.user.authentication')"
to="/user/authentication" />
</v-tabs> </v-tabs>
</template> </template>
</v-toolbar> </v-toolbar>
......
<template>
<div
v-if="loggedIn">
<UserToolbar />
<v-window v-model="tab">
<v-window-item>
<v-card
:title="$t('pages.settings.subpages.authentication.title')"
:subtitle="$t('pages.settings.subpages.authentication.subtitle')"
variant="flat"
rounded="0">
<v-card-text>
<v-form
v-model="valid2">
<v-row dense>
<v-col md="6">
<v-text-field
v-model="password"
type="password"
:rules="[v => !!v || $t('validation.required')]"
required
:variant="inputVariant"
persistent-hint
:label="$t('pages.settings.subpages.authentication.password.label')"
:hint="$t('pages.settings.subpages.authentication.password.hint')" />
</v-col>
</v-row>
<v-row dense>
<v-col md="6">
<v-text-field
v-model="password2"
type="password"
:rules="[v => !!v || $t('validation.required'), v => (!!v && v) === password || $t('Not matching!')]"
required
:variant="inputVariant"
persistent-hint
:label="$t('pages.settings.subpages.authentication.confirm.label')"
:hint="$t('pages.settings.subpages.authentication.confirm.hint')" />
</v-col>
</v-row>
<v-row>
<v-col md="6">
<v-btn
size="small"
color="secondary"
:loading="loadingUpdate"
:disabled="!valid2"
variant="flat"
type="submit"
:text="$t('pages.settings.subpages.authentication.submit.text')"
@click="changePassword" />
</v-col>
</v-row>
</v-form>
</v-card-text>
</v-card>
</v-window-item>
</v-window>
<v-breadcrumbs :items="items" class="pa-0 mt-2" />
</div>
</template>
<script setup>
const { loggedIn, user } = useOidcAuth()
</script>
<script>
import UserToolbar from '@/components/user/UserToolbar.vue'
import { useCacheStore } from '@/stores/cache.js'
export default {
components: {
UserToolbar
},
data () {
return {
tab: 0,
valid1: false,
valid2: false,
loadingUpdate: false,
items: [
{
title: this.$t('navigation.user'),
to: '/user'
},
{
title: this.$t('toolbars.user.authentication'),
to: `/user/authentication`,
disabled: true
}
],
email: null,
password: null,
password2: null,
cacheStore: useCacheStore()
}
},
computed: {
cacheUser () {
return this.cacheStore.getUser
},
inputVariant () {
const runtimeConfig = useRuntimeConfig()
return this.$vuetify.theme.global.name.toLowerCase().endsWith('contrast') ? runtimeConfig.public.variant.input.contrast : runtimeConfig.public.variant.input.normal
},
buttonVariant () {
const runtimeConfig = useRuntimeConfig()
return this.$vuetify.theme.global.name.toLowerCase().endsWith('contrast') ? runtimeConfig.public.variant.button.contrast : runtimeConfig.public.variant.button.normal
}
},
methods: {
changePassword () {
this.loadingUpdate = true
const userService = useUserService()
userService.updatePassword(this.cacheUser.uid, {'password': this.password})
.then(() => {
const user = Object.assign({}, this.cacheUser)
user.setup_finished = true
this.cacheStore.setUser(user)
// fixme [mweise]: currently nuxt-oidc-auth cannot refresh the session correctly
const toast = useToastInstance()
toast.success(this.$t('success.user.password'))
this.loadingUpdate = false
})
.catch(({code, message}) => {
const toast = useToastInstance()
if (typeof code !== 'string') {
return
}
toast.error(message)
this.loadingUpdate = false
})
.finally(() => {
this.loadingUpdate = false
})
}
}
}
</script>
No preview for this file type
...@@ -17,6 +17,7 @@ build-metadata-service: ## Build the Metadata Service. ...@@ -17,6 +17,7 @@ build-metadata-service: ## Build the Metadata Service.
.PHONY: build-auth-event-listener .PHONY: build-auth-event-listener
build-auth-event-listener: ## Build the Auth Service Event Listener. build-auth-event-listener: ## Build the Auth Service Event Listener.
mvn -f ./dbrepo-auth-service/listeners/pom.xml clean package -DskipTests mvn -f ./dbrepo-auth-service/listeners/pom.xml clean package -DskipTests
cp ./dbrepo-auth-service/listeners/target/create-event-listener.jar ./helm/dbrepo/files/create-event-listener.jar
.PHONY: build-ui .PHONY: build-ui
build-ui: ## Build the UI. build-ui: ## Build the UI.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment