Refactored token generation into module. Move authentication logic into User schema. Use promise to perform async mongodb save.