Complete rewrite to use the already existing auth_redirect hook.