package ee.tuleva.onboarding.auth.smartid;

import ee.sk.smartid.AuthenticationIdentity;
import ee.sk.smartid.SmartIdAuthenticationResult;
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@RequiredArgsConstructor
public class SmartIdSession implements Serializable {
    public final String verificationCode;
    private boolean valid = false;
    private List<String> errors = new ArrayList<>();
    private String givenName;
    private String surName;
    private String identityCode;
    private String country;

    public void setAuthenticationResult(SmartIdAuthenticationResult result) {
        if (result.isValid()) {
            valid = true;
            AuthenticationIdentity identity = result.getAuthenticationIdentity();
            givenName = identity.getGivenName();
            surName = identity.getSurName();
            identityCode = identity.getIdentityCode();
            country = identity.getCountry();
        } else {
            valid = false;
            errors.addAll(result.getErrors());
        }
    }
}

@@ -190,16 +190,50 @@
 tructor;
+%0Aimport lombok.extern.slf4j.Slf4j;
 %0A%0Aimport
@@ -338,16 +338,23 @@
 tructor%0A
+@Slf4j%0A
 public c
@@ -1152,16 +1152,68 @@
 ors());%0A
+            log.info(%22SmartID errors: %7B%7D%22, errors);%0A
         

Add SmartID errors logging