Commit e2f43e40 authored by michael.simon's avatar michael.simon
Browse files

Add identityId to session

change some methods to use identityId directly instead of userId.
parent 720314df
......@@ -20,8 +20,8 @@ public interface ProjectService extends BaseService<ProjectEntity, Long> {
List<ProjectEntity> findByService(ServiceEntity service);
ProjectEntity save(ProjectEntity project, Long userId);
ProjectEntity save(ProjectEntity project, Long identityId);
List<ProjectEntity> findAdminByUserId(Long userId);
List<ProjectEntity> findAdminByUserId(Long identityId);
}
......@@ -41,14 +41,14 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectEntity, Long> imp
}
@Override
public List<ProjectEntity> findAdminByUserId(Long userId) {
IdentityEntity identity = identityDao.findByUserId(userId);
public List<ProjectEntity> findAdminByUserId(Long identityId) {
IdentityEntity identity = identityDao.findById(identityId);
return dao.findAdminByIdentity(identity);
}
@Override
public ProjectEntity save(ProjectEntity project, Long userId) {
IdentityEntity identity = identityDao.findByUserId(userId);
public ProjectEntity save(ProjectEntity project, Long identityId) {
IdentityEntity identity = identityDao.findById(identityId);
project = dao.persist(project);
dao.addAdminToProject(project, identity, ProjectAdminType.OWNER);
......
......@@ -149,6 +149,7 @@ public class SamlSpPostServiceImpl implements SamlSpPostService {
}
session.setUserId(user.getId());
session.setIdentityId(user.getIdentity().getId());
session.setLoginTime(Instant.now());
session.setTheme(user.getTheme());
session.setLocale(user.getLocale());
......
......@@ -34,9 +34,13 @@ public class SessionManager implements Serializable {
private Long authnRequestId;
private Long authnRequestIdpConfigId;
// userId of first login process used
private Long userId;
// identityId of the actual user
private Long identityId;
private Long idpId;
private Long spId;
......@@ -285,4 +289,12 @@ public class SessionManager implements Serializable {
public void setLoginTime(Instant loginTime) {
this.loginTime = loginTime;
}
public Long getIdentityId() {
return identityId;
}
public void setIdentityId(Long identityId) {
this.identityId = identityId;
}
}
......@@ -177,6 +177,7 @@ public class RegisterUserBean implements Serializable {
}
sessionManager.setUserId(entity.getId());
sessionManager.setIdentityId(entity.getIdentity().getId());
if (sessionManager.getOriginalRequestPath() != null) {
String orig = sessionManager.getOriginalRequestPath();
......
......@@ -17,7 +17,6 @@ import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.project.ProjectEntity;
import edu.kit.scc.webreg.service.project.ProjectService;
import edu.kit.scc.webreg.session.SessionManager;
......@@ -44,7 +43,7 @@ public class ProjectAdminAddProjectBean implements Serializable {
}
public String save() {
entity = service.save(entity, session.getUserId());
entity = service.save(entity, session.getIdentityId());
return ViewIds.PROJECT_INDEX + "&faces-redirect=true";
}
......
......@@ -42,7 +42,7 @@ public class ProjectAdminListProjectBean implements Serializable {
public List<ProjectEntity> getProjectList() {
if (projectList == null) {
projectList = projectService.findAdminByUserId(session.getUserId());
projectList = projectService.findAdminByUserId(session.getIdentityId());
}
return projectList;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment