Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softRemovable not in place when creating new user #24

Open
dalgard opened this issue Jan 25, 2015 · 2 comments
Open

softRemovable not in place when creating new user #24

dalgard opened this issue Jan 25, 2015 · 2 comments

Comments

@dalgard
Copy link

dalgard commented Jan 25, 2015

Applying behaviours to the Meteor.users collection is working fine like this:

CollectionBehaviours.extendCollectionInstance(Meteor.users);
Meteor.users.softRemovable();

When I delete a user, the document remains in the database, but is not returned from Meteor.users.find() – great! The problem arises when the user tries to create a new account with the same e-mail. Meteor says that a user already exists with that e-mail.

Anything I/we can do about this? Thanks.

@dalgard dalgard changed the title softRemovable not applied when creating new user softRemovable not in place when creating new user Jan 25, 2015
@dalgard
Copy link
Author

dalgard commented May 10, 2015

I've solved this by redefining the softRemovable behaviour. It's only a small change. In the new version, when applying the behaviour, a modifier object can be passed as an argument.

The new modifier (defaulted to an empty object) is then extended (using _.default) with the base modifier used inside the .before.update hook, which would normally just $set removed and removedAt. The new modifier is used in place of the base modifier in the update operation.

In regard to the Meteor.users collection, I pass the object below as the new modifier – this way, when creating new users in the future, the duplicate check comes out negative.

Meteor.users.softRemovable({
  $rename: {
    "emails": "removedEmails",
    "services": "removedServices"
  }
});

@zimme
Copy link

zimme commented Jun 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants