mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-06 10:06:21 +02:00
Delete api keys when user is deleted
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
import com.github.legman.Subscribe;
|
||||
import com.google.common.util.concurrent.Striped;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -31,8 +32,10 @@ import org.apache.shiro.authc.credential.PasswordService;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.HandlerEventType;
|
||||
import sonia.scm.store.DataStore;
|
||||
import sonia.scm.store.DataStoreFactory;
|
||||
import sonia.scm.user.UserEvent;
|
||||
import sonia.scm.user.UserPermissions;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -176,6 +179,13 @@ public class ApiKeyService {
|
||||
.anyMatch(key -> key.getDisplayName().equals(name));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void cleanupForDeletedUser(UserEvent userEvent) {
|
||||
if (userEvent.getEventType() == HandlerEventType.DELETE) {
|
||||
store.remove(userEvent.getItem().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class CreationResult {
|
||||
|
||||
Reference in New Issue
Block a user