sigmike/peer4commit — pull request #23 by kuldeepaggarwal (2014-02-23 16:11:47+00:00)
Title: minor optimisation.

1. optimize login_token generation.

Whenever we are generating the login_token for a user, currently, it is firing 2 queries to the DB, 1 for the 'create' and 1 for the 'update' login_token statement.

If we set the login_token in a :before_create callback we would still have the update within the transaction plus the login_token would get saved in the 'create' statement itself.

2. create unique login token for each user.

We were setting login token using SecureRandom.urlsafe_base64 before user's creation and login token is unique for each user, so we must ensure that it should be unique for all users.