implement PATCH route for user and factor out some common stuff