ADDED: redirect to custom uri with custom referer if not authenticated