mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 21:57:56 +01:00
Remove orphan collabs on registration
This commit is contained in:
parent
07ad57e3b4
commit
63cfe44d50
@ -102,22 +102,29 @@ public class UserManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public User createUser(@NotNull User user, @NotNull Collaborator col) {
|
||||
public User createUser(@NotNull User user, @NotNull Collaborator collaborator) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
final Set<Collaboration> set = col.getCollaborations();
|
||||
for (Collaboration collaboration : set) {
|
||||
final Set<Collaboration> collaborations = collaborator.getCollaborations();
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
// Move maps to the new ...
|
||||
Collaboration newMapUser = new Collaboration();
|
||||
newMapUser.setRoleId(collaboration.getRole().ordinal());
|
||||
newMapUser.setMindMap(collaboration.getMindMap());
|
||||
newMapUser.setCollaborator(user);
|
||||
user.addCollaboration(newMapUser);
|
||||
|
||||
// Delete collaborations on this collaborator ...
|
||||
getHibernateTemplate().delete(collaboration);
|
||||
getHibernateTemplate().flush();
|
||||
}
|
||||
|
||||
getHibernateTemplate().delete(col);
|
||||
// Delete collaboration ...
|
||||
getHibernateTemplate().delete(collaborator);
|
||||
getHibernateTemplate().flush();
|
||||
getHibernateTemplate().saveOrUpdate(user);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@ -46,7 +49,6 @@ public class Collaboration implements Serializable {
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "properties_id", nullable = false, unique = true)
|
||||
private CollaborationProperties collaborationProperties = new CollaborationProperties();
|
||||
;
|
||||
|
||||
public Collaboration() {
|
||||
}
|
||||
|
@ -55,8 +55,6 @@ public class AccountController extends BaseController {
|
||||
@Autowired
|
||||
private NotificationService notificationService;
|
||||
|
||||
final Logger logger = Logger.getLogger(AccountController.class);
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "account/password", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
|
@ -119,13 +119,11 @@ public class UserServiceImpl
|
||||
|
||||
if (emailConfirmEnabled) {
|
||||
user.setActivationDate(null);
|
||||
|
||||
} else {
|
||||
user.setActivationDate(Calendar.getInstance());
|
||||
}
|
||||
|
||||
Collaborator col = userManager.getCollaboratorBy(user.getEmail());
|
||||
|
||||
final Collaborator col = userManager.getCollaboratorBy(user.getEmail());
|
||||
if (col != null) {
|
||||
userManager.createUser(user, col);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user