Revised User.authenticate method logic