mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Fix sharing of man on new collabs.
This commit is contained in:
parent
63cfe44d50
commit
1f99ce3889
@ -105,19 +105,20 @@ public class UserManagerImpl
|
|||||||
public User createUser(@NotNull User user, @NotNull Collaborator collaborator) {
|
public User createUser(@NotNull User user, @NotNull Collaborator collaborator) {
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||||
assert user != null : "Trying to store a null user";
|
assert user != null : "Trying to store a null user";
|
||||||
|
getHibernateTemplate().saveOrUpdate(user);
|
||||||
|
|
||||||
|
// Migrate from previous temporal collab to new user ...
|
||||||
final Set<Collaboration> collaborations = collaborator.getCollaborations();
|
final Set<Collaboration> collaborations = collaborator.getCollaborations();
|
||||||
for (Collaboration collaboration : collaborations) {
|
for (Collaboration oldCollab : collaborations) {
|
||||||
// Move maps to the new ...
|
Collaboration newCollab = new Collaboration();
|
||||||
Collaboration newMapUser = new Collaboration();
|
newCollab.setRoleId(oldCollab.getRole().ordinal());
|
||||||
newMapUser.setRoleId(collaboration.getRole().ordinal());
|
newCollab.setMindMap(oldCollab.getMindMap());
|
||||||
newMapUser.setMindMap(collaboration.getMindMap());
|
newCollab.setCollaborator(user);
|
||||||
newMapUser.setCollaborator(user);
|
user.addCollaboration(newCollab);
|
||||||
user.addCollaboration(newMapUser);
|
getHibernateTemplate().save(newCollab);
|
||||||
|
|
||||||
// Delete collaborations on this collaborator ...
|
// Delete collaborations on this collaborator ...
|
||||||
getHibernateTemplate().delete(collaboration);
|
getHibernateTemplate().delete(oldCollab);
|
||||||
getHibernateTemplate().flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete collaboration ...
|
// Delete collaboration ...
|
||||||
@ -143,8 +144,7 @@ public class UserManagerImpl
|
|||||||
|
|
||||||
// Does the password need to be encrypted ?
|
// Does the password need to be encrypted ?
|
||||||
final String password = user.getPassword();
|
final String password = user.getPassword();
|
||||||
if(password!=null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith( "{"+ DefaultPasswordEncoderFactories.ENCODING_ID)))
|
if (password != null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith("{" + DefaultPasswordEncoderFactories.ENCODING_ID))) {
|
||||||
{
|
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public class UserManagerImpl
|
|||||||
query.setParameter("activationCode", code);
|
query.setParameter("activationCode", code);
|
||||||
final List users = query.list();
|
final List users = query.list();
|
||||||
|
|
||||||
if(users != null && !users.isEmpty()) {
|
if (users != null && !users.isEmpty()) {
|
||||||
|
|
||||||
assert users.size() == 1 : "More than one user with the same username!";
|
assert users.size() == 1 : "More than one user with the same username!";
|
||||||
user = (User) users.get(0);
|
user = (User) users.get(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user