<script>//redirect to ARB login if accessing arb application
if(window.location.href.toLowerCase().includes("os_destination")){
	if(window.location.href.toLowerCase().includes("application%2b2021%2bsa")){
		window.location.replace("/display/AN/EWC+Login+ARB?os_destination=%2Fpages%2Fviewpage.action%3FspaceKey%3DAPP%26title%3DApplication%2B2021%2BSA");
	}
}
</script>





<script>
let rediUrl = ""
if(window.location.href.toLowerCase().includes("os_destination")){
		rediUrl = window.location.href.split("os_destination=")[1]
	} else {
    	rediUrl = "/dashboard.action"
	}
// Endpoint checks if authenticated user is part of smith group otherwise add and send email
jQuery.ajax({
  url: "/rest/scriptrunner/latest/custom/ewcAutoMemberShip",
  headers: {
    'X-Atlassian-Token' : 'nocheck',
    'Content-type' : 'application/json'
  },
  type: "POST",
  dataType: 'text',
  data: JSON.stringify({
    "email": AJS.params.remoteUser,
  }),
  success: function(text){
    //console.log("Response: "+ text)
	window.location.replace(rediUrl)
  },
  error: function(err){
    //alert(err)
	window.location.replace("https://platform.entrepreneurshipworldcup.com/");
  }
});



</script>



<style>


.main-container {
    min-height: calc(100vh - 50px);
    background-repeat: no-repeat;
    background-size: cover;
}

div#toggle {
    display: none;
}
</style>