Skip to content

Commit

Permalink
Merge pull request #507 from WISVCH/walletfixes
Browse files Browse the repository at this point in the history
Wallet: Remove the requirement to be authenticated, add fallback when no location is set
  • Loading branch information
dsluijk authored Sep 29, 2024
2 parents fd2776b + ccc1b72 commit aa5e292
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 54 deletions.
68 changes: 34 additions & 34 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java-postgres
{
"name": "Java & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/java:1": {
"installGradle": "true"
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or with the host.
"forwardPorts": [
1080, // Mailcatcher
5432, // PostgreSQL
8080, // Events
8082 // Adminer
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gradle bootRun",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"vmware.vscode-boot-dev-pack",
"vscjava.vscode-gradle",
"vscjava.vscode-java-pack"
]
}
}
}
"name": "Java & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/java:1.6.0": {
"installGradle": "true"
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or with the host.
"forwardPorts": [
1080, // Mailcatcher
5432, // PostgreSQL
8080, // Events
8082 // Adminer
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gradle bootRun",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"vmware.vscode-boot-dev-pack",
"vscjava.vscode-gradle",
"vscjava.vscode-java-pack"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ private EventTicketClass createClass(Product product) {
.setDescription("Terms & Conditions")
.setId("LINK_GTC");

String locationName = product.getEvent().getLocation();

if(locationName == null || locationName.trim().isEmpty()) {
locationName = "Unknown";
}

return new EventTicketClass()
.setId(this.getClassId(product))
.setIssuerName("Christiaan Huygens")
Expand All @@ -120,7 +126,7 @@ private EventTicketClass createClass(Product product) {
.setUri(homePage)
.setDescription("Events"))
.setVenue(new EventVenue()
.setName(this.makeLocalString(product.getEvent().getLocation()))
.setName(this.makeLocalString(locationName))
.setAddress(this.makeLocalString("Mekelweg 4, 2628 CD Delft")))
.setDateTime(new EventDateTime()
.setStart(this.formatDate(product.getEvent().getStart()))
Expand All @@ -143,6 +149,7 @@ private EventTicketObject createObject(Ticket ticket) {
.setHexBackgroundColor("#1e274a")
.setFaceValue(cost)
.setBarcode(new Barcode().setType("QR_CODE").setValue(ticket.getUniqueCode()))
.setGroupingInfo(new GroupingInfo().setGroupingId(ticket.product.event.getKey()).setSortIndex(1))
.setLinksModuleData(new LinksModuleData().setUris(Arrays.asList(tnc)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ public Ticket transfer(Ticket ticket, Customer currentCustomer, Customer newCust
public byte[] getApplePass(Ticket ticket) throws TicketPassFailedException {
try {
RestTemplate restTemplate = new RestTemplate();


Map<String, String> params = new HashMap<>();

params.put("title", ticket.getProduct().getTitle());
params.put("description", ticket.getProduct().getDescription());
params.put("date", ticket.getProduct().getEvent().getStart().format(DateTimeFormatter.ISO_LOCAL_DATE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,9 @@ public WebshopPassesController(
* Get wallet pass of ticket.
*/
@GetMapping("/apple/{key}/wallet.pkpass")
public void getApplePass(HttpServletResponse response, @PathVariable String key) throws IOException {
Customer customer = authenticationService.getCurrentCustomer();

public void getApplePass(HttpServletResponse response, @PathVariable String key) throws IOException {
try {
Ticket ticket = ticketService.getByKey(key);

if (!ticket.owner.equals(customer) && ticket.owner.isVerifiedChMember()) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}

byte[] bytes = ticketService.getApplePass(ticket);

response.setContentType("application/vnd.apple.pkpass");
Expand All @@ -68,17 +60,10 @@ public void getApplePass(HttpServletResponse response, @PathVariable String key
*/
@GetMapping("/google/{key}")
public void getGooglePass(HttpServletResponse response, @PathVariable String key) throws IOException {
Customer customer = authenticationService.getCurrentCustomer();

try {
Ticket ticket = ticketService.getByKey(key);

if (!ticket.owner.equals(customer) && ticket.owner.isVerifiedChMember()) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}

String link = ticketService.getGooglePass(ticket);

response.sendRedirect(link);
}
catch (TicketNotFoundException e) {
Expand Down

0 comments on commit aa5e292

Please sign in to comment.