How do I get the information of the user I deleted from JPA Auditing?

Viewed 25

I'm using JPA Auditing.

And because I'm using Spring-Security, I'm automatically entering the information of the logged-in user using AuditorAware. (Using @lastModifiedByAnnotation)

The current situation is that when registering and modifying, the information of the currently logged-in user is well included, but if you delete it, the NULL value is included.

Even if I delete it, I want to let the deleted user enter lastModifiedBy, what should I do?

@Configuration
public class JpaAuditConfig implements AuditorAware<String> {
    @Override
    public Optional<String> getCurrentAuditor() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null || !authentication.isAuthenticated()) {
            return null;
        }

        return Optional.ofNullable(((Member) authentication.getPrincipal()).getName());

    }
}
0 Answers
Related