removed auth from picture upload

This commit is contained in:
verboomp
2026-02-02 08:13:28 +01:00
parent 94c6becf9f
commit 33ee33d55c
7 changed files with 29 additions and 31 deletions

2
.gitignore vendored
View File

@@ -59,7 +59,7 @@ hartmann-foto-documentation-frontend/pubspec.lock
.flutter-plugins-dependencies
hartmann-foto-documentation-docker/src/main/docker/hartmann-foto-documentation-web-*.war
hartmann-foto-documentation-docker/src/main/docker/hartmann-foto-documentation-web-*.war
hartmann-foto-documentation-web/src/main/webapp/.last_build_id
hartmann-foto-documentation-web/src/main/webapp/assets/

View File

@@ -39,7 +39,6 @@
<dependencies>
<!-- Elytron secrity used for username/password login -->
<dependency>
<groupId>org.wildfly.security</groupId>

View File

@@ -116,7 +116,7 @@ public class CustomerPictureService extends AbstractService {
criteriaQuery = criteriaQuery.where(builder.and(predicates.toArray(new Predicate[0])));
}
//criteriaQuery = criteriaQuery.orderBy(builder.asc(builder.lower(customerRoot.get("name")))); FIXME: this causes errors
//criteriaQuery = criteriaQuery.orderBy(builder.asc(builder.lower(customerRoot.get("name")))); //FIXME: this causes errors
TypedQuery<Customer> typedQuery = entityManager.createQuery(criteriaQuery);
List<Customer> customers = typedQuery.getResultList();

View File

@@ -52,12 +52,12 @@ public class CustomerPictureResource {
@Operation(summary = "Add Customer Image to database")
@ApiResponse(responseCode = "200", description = "Add successfull")
public Response doAddCustomerPicture(@Context HttpServletRequest httpServletRequest, @JsonSchemaValidate("schema/customer_picture_add.json") CustomerPictureValue customerPictureValue) {
Optional<SecurityIdentity> identity = loginUtils.authenticate(httpServletRequest);
/*Optional<SecurityIdentity> identity = loginUtils.authenticate(httpServletRequest);
if (identity.isEmpty()) {
LOG.debug("identity empty login invalid");
return Response.status(Status.UNAUTHORIZED).build();
}
*/
boolean success = customerPictureService.addCustomerPicture(customerPictureValue);
return success ? Response.ok().build() : Response.status(Status.BAD_REQUEST).build();
}

View File

@@ -44,11 +44,11 @@ public class CustomerPictureResourceTest extends AbstractRestTest {
assertEquals(3, customerCount());
assertEquals(5, pictureCount());
String authorization = getBasicHeader();
LOG.info("authorization: " + authorization);
//String authorization = getBasicHeader();
//LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH;
Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization)
//.addHeader("Authorization", authorization)
.bodyFile(new File(BASE_UPLOAD + "add.json"), ContentType.APPLICATION_JSON);
HttpResponse httpResponse = executeRequest(request);
@@ -102,6 +102,7 @@ public class CustomerPictureResourceTest extends AbstractRestTest {
System.out.println(text);
}
/*
@Test
@Order(1)
public void doAddCustomerPictureNoAuth() throws IOException {
@@ -115,7 +116,7 @@ public class CustomerPictureResourceTest extends AbstractRestTest {
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(401, code);
}
*/
public static void main(String[] args) throws IOException {
var test = new CustomerPictureResourceTest();

View File

@@ -63,18 +63,6 @@ class _CustomerWidgetState extends State<CustomerWidget> {
}
if (snapshot.hasData) {
CustomerDto? dto = snapshot.data;
return _mainWidget(dto);
} else if (snapshot.hasError) {
var error = snapshot.error;
return (error is ServerError) ? GeneralErrorWidget.fromServerError(error) : GeneralErrorWidget(error: snapshot.error.toString());
}
return const WaitingWidget();
},
);
}
Widget _mainWidget(CustomerDto? dto) {
if (dto == null) {
return Text(
AppLocalizations.of(context)!.customerWidgetNotFound,
@@ -86,7 +74,17 @@ class _CustomerWidgetState extends State<CustomerWidget> {
),
);
}
return _mainWidget(dto);
} else if (snapshot.hasError) {
var error = snapshot.error;
return (error is ServerError) ? GeneralErrorWidget.fromServerError(error) : GeneralErrorWidget(error: snapshot.error.toString());
}
return const WaitingWidget();
},
);
}
Widget _mainWidget(CustomerDto dto) {
var subText = AppLocalizations.of(context)!.customerWidgetCustomerNumberPrefix(dto.customerNumber);
return Column(
mainAxisAlignment: MainAxisAlignment.start,
@@ -97,7 +95,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
_downloadButton(context),
_downloadButton(context, dto),
],
),
const SizedBox(height: 24),
@@ -263,7 +261,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
Icons.file_download_outlined,
color: _generalStyle.loginFormTextLabelColor,
),
onPressed: () => _actionDelete(context, customerDto, pictureDto),
onPressed: () => _actionDownload(context, customerDto, pictureDto),
),
),
SizedBox(
@@ -283,10 +281,10 @@ class _CustomerWidgetState extends State<CustomerWidget> {
);
}
Widget _downloadButton(BuildContext context) {
Widget _downloadButton(BuildContext context, CustomerDto customerDto) {
return ElevatedButton.icon(
key: Key("download_all_button"),
onPressed: () => _actionDownload(context),
onPressed: () => _actionDownload(context, customerDto, null),
iconAlignment: IconAlignment.end,
icon: Icon(
Icons.file_download_outlined,
@@ -335,7 +333,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
});
}
Future<void> _actionDownload(BuildContext context) async {
Future<void> _actionDownload(BuildContext context, CustomerDto customerDto, PictureDto? pictureDto) async {
// FIXME: implement a download from the export
}
}