Added error handling for nil user object in auth.