Refactor login recording code, and use it in registration.js too.