Update settings and redirect middleware