Skip to content
Snippets Groups Projects
Commit 50d73122 authored by Michael Simon's avatar Michael Simon
Browse files

NO_STORY do extra check when unlinking user from identity

parent d5faca28
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,6 @@ public interface UserDeleteService {
void deleteUserData(IdentityEntity identity, String executor);
void unlinkAndDeleteAccount(UserEntity user, String executor);
void unlinkAndDeleteAccount(UserEntity user, IdentityEntity checkIdentity, String executor);
}
......@@ -116,8 +116,13 @@ public class UserDeleteServiceImpl implements UserDeleteService {
private EventSubmitter eventSubmitter;
@Override
public void unlinkAndDeleteAccount(UserEntity user, String executor) {
public void unlinkAndDeleteAccount(UserEntity user, IdentityEntity checkIdentity, String executor) {
user = userDao.fetch(user.getId());
if (! user.getIdentity().equals(checkIdentity)) {
throw new IllegalArgumentException("check identity");
}
IdentityEntity identity = user.getIdentity();
logger.info("Unlink and delete user account {} from identity {}", user.getId(), identity.getId());
......
......@@ -14,12 +14,6 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import jakarta.faces.context.FacesContext;
import jakarta.faces.event.ComponentSystemEvent;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.slf4j.Logger;
import edu.kit.scc.webreg.entity.RegistryEntity;
......@@ -32,6 +26,11 @@ import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.identity.IdentityService;
import edu.kit.scc.webreg.session.SessionManager;
import edu.kit.scc.webreg.util.ViewIds;
import jakarta.faces.context.FacesContext;
import jakarta.faces.event.ComponentSystemEvent;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
@Named
@ViewScoped
......@@ -71,7 +70,7 @@ public class UnlinkAndDeleteAccountBean implements Serializable {
}
public String commit() {
userDeleteService.unlinkAndDeleteAccount(getUser(), "identity-" + getIdentity().getId());
userDeleteService.unlinkAndDeleteAccount(getUser(), getIdentity(), "identity-" + getIdentity().getId());
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("/logout/local?redirect=unlink_and_delete_account");
} catch (IOException e) {
......@@ -81,8 +80,12 @@ public class UnlinkAndDeleteAccountBean implements Serializable {
}
public UserEntity getUser() {
if (user == null)
if (user == null) {
user = userService.fetch(id);
if (! user.getIdentity().equals(getIdentity())) {
throw new IllegalArgumentException("not authorized");
}
}
return user;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment