add require_login check before trying to redirect.