enhance logging and fix Null pointer exception at wifi Null

This commit is contained in:
heyethereum
2024-08-12 00:51:35 +08:00
parent 3b2533bb62
commit a71cbd3093
5 changed files with 18 additions and 11 deletions

View File

@@ -52,7 +52,7 @@ public class QRCodeTypeController {
@PostMapping(value = API_URL_QRCODE_SCAN, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BaseScanResponse> scanQRCode(@RequestBody QRCodePayload payload,
@RequestHeader(required = false, name = HEADER_USER_ID) String userId) {
logger.info("Invoking scan endpoint");
logger.info("User Id Invoking scan endpoint: {}", userId);
return ResponseEntity.ok(qrCodeTypeService.scanQRCode(userId, payload));
}

View File

@@ -2,6 +2,7 @@ package com.safeqr.app.qrcode.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -31,6 +32,7 @@ public class WifiEntity {
private String ssid;
private String password;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String encryption;
private boolean hidden;
}

View File

@@ -60,6 +60,11 @@ public class WifiVerificationService {
}
public String getClassification(String encryptionType) {
// Check if encryptionType is null
if (encryptionType == null) {
return CLASSIFY_UNSAFE;
}
if (encryptionType.equalsIgnoreCase("WPA") ||
encryptionType.equalsIgnoreCase("WPA2") ||
encryptionType.equalsIgnoreCase("WPA3")) {