I have 'users' collections with the following structure:
_id: ObjectId(...),
name: 'Erik',
email: 'erik@mail.com'
I need to use signup confirmation via email, so I need yours advice for the following approach:
Create TTL index on that collection for confirm field:
db.users.ensureIndex({"confirm": 1}, {expireAfterSeconds: 60*60*1000});
When user sign up, then create this one with confirm as current time:
db.users.create({name: 'name', email: 'email', confirm: new Date()});
When user send request for confirming your account we update his confirm field to true because we don't want that user to be removed by TTL index:
db.users.update({email: req.param('email'), {confirm: true}});
I want know the following:
- Is the approach above correct.
- Is the approach above secure